Exercise Mutations

Tell us what’s happening:

On the console its returning false on this specific case just as I wanted, but its not getting accepted because its saying on those checkboxes in the bottom of the page that its not returning false. :confused:
I`m quite confused.
pls, can someont hep??
Your code so far

function mutation(arr) {
  var aux = "";
  for(var i =0; i < arr[0].length; i++)
    hash[(arr[0][i]).toLowerCase()] = 1;
  for(var j=0; j < arr[1].length; j++)
      return false;
  return true;
var hash = {};

mutation(["vodo", "no"]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0.

Link to the challenge:

You need to move the following variable initialization to be inside the function.

var hash = {};

Why? Because the FCC tests are ran sequentially and any global variables will retain their value between each execution of the tests. So, if you leave the global variable, then hash will keep growing and eventually affect the results of the other tests. Keeping it inside the function, makes sure it gets reset to an empty object during each test.

After the test mutation([“zyxwvutsrqponmlkjihgfedcba”, “qrstu”]); executes, hash has all the letters as properties, so, all the remaining tests return true. The problem is, the last two should return false.

1 Like

Thank you so much :smiley: