Need help on Mutations challenge

Tell us what’s happening:

The first two works works fine, but the rest of them will return false. I honestly don’t understand what is happening anymore.

Your code so far


function mutation(arr) {
var strA = arr[0].toLowerCase()
var strB = arr[1].toLowerCase()
for (var i = 0; i < arr.length; i++){
  if(strA === strB){
    return true
  } else {
    return false
  }
}
}
console.log(mutation(["hello", "hey"]))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36.

Challenge: Mutations

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations

Your current code is only checking if the 2 strings are the same, with ignoring case:

 if(strA === strB){
    return true

case IS part of the challenge, but so is the order of letters;
console.log(mutation([ "ABC", "cba" ])) should also return true

1 Like

So what I have to do is not ignore the case sensitive, right?

you want to ignore case and positioning… again so ABC & cba would be true.

1 Like