I fail at 1 test case, but i pass the rest. I can't understand the problem statement properly

Tell us what’s happening:
Only test case that has failed: mutation([“ate”, “date”]) should return false.
Your code so far

function mutation(arr) {
let isTrue = false;
let first = (arr[0].length >= arr[1].length)?arr[1]:arr[0];
let second = (arr[0].length < arr[1].length)?arr[1]:arr[0];
for(let i=0;i<first.length;i++){
  for(let j=0;j<second.length;j++){
    if(first[i].toLowerCase() === second[j].toLowerCase()){
      isTrue = true;
    else isTrue = false;
  if(!isTrue) return isTrue;
return isTrue;

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/89.0.4389.90 Safari/537.36.

Challenge: Mutations

Link to the challenge:

periods and dashes? i can’t anything wrong. Please help!!! @BIG-OLD-TOILET

I am having difficulty understanding your algorithm here. The basic algorithm is:

  1. Start at the first character of the array’s second element.
  2. Is character found anywhere in the array’s first element? If the answer is no, then return false and stop. Otherwise, continue to the next step.
  3. Is character the last one in the array’s second element?
  4. If yes, return true. Otherwise, move to the next character in the array’s second element and go back to step 2.

Since you are not supposed to care about the case of the letters, you can convert both array elements to lowercase before iterating through the second element’s characters. This greatly simplifies the code.

I understood my mistake. What i did was check which among the two strings are the smallest and then did the comparisons. Thank you @RandellDawson

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.