Creating a personalized formula in Google Sheets to determine the level of disagreement between individuals

I need assistance creating a custom function in Google Sheets using JavaScript to determine the level of disagreement between survey participants.

Below is my current code snippet:

function disagree(DISAG,otherMember) {
  var otherMember = '';
  var indivDisag = DISAG.localeCompare(otherMember);
  return Math.abs(indivDisag);
}

Despite utilizing localCompare, I am consistently receiving a value of 1 instead of the expected 0 for similar responses. Can you identify what mistake I've made?

This simple function allows me to compare the disagreement between two individuals based on their responses.

Updated for clarity.

Thank you for your guidance.

Answer №1

In the scenario where you consistently assign otherMember to an empty string of '', it is logical that a disparity will always exist. Perhaps you could experiment with this alternative approach:

function dissent(DISAGREE, otherMember) {
  return Math.abs(DISAGREE.localeCompare(otherMember));
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue warning: Issue encountered in created hook - Attempting to access property 'get' of an undefined variable is causing a TypeError

I encountered an error while using axios: [Vue warn]: Error in created hook: "TypeError: Cannot read property 'get' of undefined" export default { methods: { loadUsers(){ axios.get("api/user").then(data => ...

Developing a spreadsheet through Titanium

Currently working on a new project that involves utilizing an SQLite database and requires exporting the data to a .xlsx file through programming. I've searched online for solutions without much luck. Is there a method available within Titanium Appcel ...

A guide on converting JSON strings into arrays using Javascript

In my JavaScript program, I have a Mocha test that checks if all available currencies are displayed in a drop-down list: it('displays all available currencies in drop down list', () => { return invoiceEditPage.details.currencyDropDown.dr ...

What could be causing my code to fail in properly iterating through the array of objects in React using the id as the key?

I have successfully printed the blog array in the console, which includes the object. My goal is to utilize the object components by mapping through the id as the key, but I am unable to access the map function. Interestingly, I have used a similar map s ...

Forced line break at particular point in text

I would love to implement a line break right before the "+" character, either using css styling or through a different method. Is this task achievable? #myDiv{ width: 80% } #myP{ c ...

A Simple Guide to Setting a Background Image in React Native with the Nativebase.io Library

What is the process for including a background image in React Native with the help of the Nativebase.io Library? I have a specific screen where I need to incorporate a background image, with all other elements positioned at the center of the image. ...

"Seeking clarification on submitting forms using JQuery - a straightforward query

My goal is to trigger a form submission when the page reloads. Here's what I have so far: $('form').submit(function() { $(window).unbind("beforeunload"); }); $(window).bind("beforeunload", function() { $('#disconnectform&apo ...

How can I deactivate the main color of the FormLabel when the focus is on the radio button group?

Is there a way to change the color of FormLabel to black instead of the primary color when the radio button group is focused? https://i.sstatic.net/h3hML.png const styles = { formLabel: { color: "#000" }, formLabelFocused: { color: "#000" ...

Removing data using axios in a React project

I'm currently working on a small app using the Json server package to help me keep track of movies I want to watch in my free time. I am looking to learn React and Axios, so I decided to build this app with these technologies. The concept is simple - ...

Recommendation for a reliable and user-friendly chat platform without the need for third-party involvement

I am in need of a chat room for a specific group of users on my social network. Ideally, I want a chat feature that is simple and does not require a third party. The chat should automatically use the user's name based on their authorized id when they ...

The routing is not functioning properly as anticipated

Here is a route definition that I am using: routes.MapRoute( "FormPreview", "Forhandsgranska/{FormId}/{action}/{id}", new { controller = "FormPreview", action = "Introduction", id = UrlParameter.Optional } ...

Functionality of Ajax: Data fields containing numerous values

I'm confused about the data fields in the ajax function. Typically, the syntax for an ajax function looks something like this: $.ajax({ url: "/aaa/bbb/ccc", method: "SomeMethod", data: someData, success: function (res ...

Unable to modify document value in MongoDB using Node.js

Currently, I am attempting to fetch the value of a field form that is being sent to a subroute and utilize it to update a database collection. My ability to retrieve the form value and manipulate it is working fine; however, I encounter an issue when I sol ...

Javascript Error - Issue with Fuse.js: e.split() function is not recognized

Scenario - I am in need of implementing a fuzzy search feature, and therefore utilizing fuse.js for this purpose. I obtained the code snippet from fuzzy.min.js at https://github.com/krisk/Fuse/blob/master/src/fuse.min.js Challenge - Despite using the cod ...

The JavaScript Ajax data is in array format, however, the length of the array

I received the following Json data: (Extracted from the console) jsonData Object {0: Object, 1: Object, 2: Object, 3: Object, 4: Object, 5: Object, 7: Object} When I enter jsonData[0] in the console, this is the output: Object {id: 125, Module_id: 2, a ...

What is causing this code to run immediately upon the addition of Promise logic?

The coding scenario written below was supposed to have two 4-second delays. However, when the code is run, it executes immediately. It seems that there might be a lack of understanding on my part regarding some basic concept, or perhaps there's a hidd ...

Scripts in jQuery Ajax are being loaded as text, with certain portions of the code undergoing processing

I encountered an issue while working on a block of code. The code I wrote is meant to load a URL from an XML file and insert server-side code into the pre tag, which displays the developed code for a class project. It works perfectly fine with Python and M ...

I am having difficulty toggling the show feature

I am currently facing an issue where I want the answer to be displayed when clicking on the question, but unfortunately, it's not working as expected. Can someone please assist me in resolving this problem? Here is my code: <html> <he ...

Exploring the scope of event listeners in jQuery's TimeCircles

Currently experimenting with the jquery timer known as "TimeCircles", which can be found here. I have successfully set up a minute / second timer for 30 minutes with an alert that triggers at 25 minutes. My goal is to implement an event when the timer hits ...

Switching CSS Unicode to JavaScript

I've been using a few emoji unicodes that work great in CSS: content: "\f410" content: "\f2d1" I attempted to display them with JavaScript, but unfortunately, I was unsuccessful. Any suggestions you have would be ...