Mutations, mutations, mutations galore

mutation([“hello”, “hey”]);
we wish to know if the letters in “hey”
can be found in “hello” so in my code I
Iooped through “hey” checking to see if
“hello”. includes( each letter letter in “hey”)
if it is found that a letter is not includes
then return false else return true

this can be done by setting var ret=true;
before starting the loop
only change ret to false is a letter
is not found so if all the letters are found
ret remains true
the last line must return ret;

Thanks. That helps a lot. Certain parts are still not passing, but This is how I set up the return so that it doesn’t immediately end the checking of the loop. Am I returning in the wrong spot?

  let answer = true; 
   let stringToCheck = arr[0].toLowerCase();
    let stringToMatch = arr[1].toLowerCase(); 
    for(let i = 0; i < stringToMatch.length; i ++){ {
     if(stringToCheck[i].includes(stringToMatch[i])){
       answer = false; 
        }
      }
    }
      return answer; 
  }

        
console.log(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]))
    
console.log(mutation(["hello", "Hello"]));

thank you for your patience guys. I feel like I didn’t earn this one with all the help i’ve needed.

this can be done by setting var ret=true;
before starting the loop
only change ret to false if a letter

is Not found so if all the letters are found

ret remains true
the last line must return ret;

your if statement checks
if it IS found

an “!” will negate the
results of your if statement
if(!1 ==1)
read that as
If Not 1 ==1(not true)

mutation([“hello”, “hey”]);
we wish to know if the letters in “hey”
can be found in “hello” so in my code I

Iooped through “hey”

checking to see if
“hello”. includes( each letter letter in “hey”)
if it is found that a letter is Not includes
then return false else return true

because you are checking each letter
of “hey” to see if it exists any where
in “hello” you must not loop through
“hello”

you are checking if one letter includes an other letter. Instead you want to know if one string includes one letter

Thank you both. Just got back from work and am back into this wretched problem. That makes sense @ILM to check the entire string to see if it includes the letter. @Da_vey I think I understand that I need to use the NOT operator to see if a string does not include the letter found in the second argument, yes? or no? I put it in the [0] position to return false if no letters are found and true else-wise. I am passing more tests for the challenge but … [‘voodoo’, ‘no’] and [
‘hello’, ‘neo’] should be showing false. Am I any closer to solving this crazy problem?


  let answer = true; 

   let stringToCheck = arr[0].toLowerCase();

    let stringToMatch = arr[1].toLowerCase(); 

    for(let i = 0; i < stringToMatch.length; i ++){

        if(!stringToCheck.includes(stringToMatch[i])){

         answer = false; 

        } else {

          answer = true;

        }

      }

      return answer; 

  }

        

console.log(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]));

console.log(mutation(["hello",  "hey"]));

console.log(mutation(["voodoo", "no"]));

console.log(mutation(["hello", "neo"]));```

this can be done by setting var ret=true;
before starting the loop
only change ret to false if a letter

is Not found

don’t set it to true
only set it to true at the top
before the loop begins

@Da_vey You are the man. Halle-freaking-lujah!!! Finally got it to pass. That was insanely difficult. Could not have done that without your extreme patience. Thanks guys, you rock!!!

no problem
I just kept posting the same thing over and over
:rofl:
I can explain but you must
do the understanding
You Da Man !

Seriously , I get vicariously high on your success at your quest for knowledge.

I noticed that too, the return statements kept tripping me up. Thanks so much