Basic Algorithm Scripting - Mutations

Tell us what’s happening:
Unable to use the .some() function. Is this course out of date?

Your code so far

function mutation(arr) {
  let arr1 = arr[0];
  let arr2 = arr[1];

  arr2.some();

  return arr;
}

mutation(["hello", "hey"]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0

Challenge: Basic Algorithm Scripting - Mutations

Link to the challenge:

What do you expect this to do?
The code above is missing a callback function. Also, its return value isn’t being assigned to anything.

I had

arr2.some(v=> arr1.indexOf(v) !== -1);

and I was being told that “some()” wasn’t a function. I tried simplifying the function to get the browser IDE to simply recognize that it is indeed a function, but was unable to do so.

Not quite. You are being told that arr2.some is not a function.

What does console.log(typeof arr2) show you? The variable name you chose is lying to you. .some is indeed not a method on the type of thing that arr2 is.

1 Like

I thought a string was a 1D array?

No. A string is a string. An array is an array. They have different prototypes with different methods defined on each.

You might be thinking of C, where there are no strings, only character arrays.

1 Like