Basic Algorithm Scripting - Mutations

Tell us what’s happening:

Please help me figure this out with explanation, I don’t think I’m doing the right loop for index

Your code so far

function mutation(arr) {
  //array mutation conversion
  const smallCaps = arr[0].toLowerCase();
  const target = arr[1].toUpperCase();

  //index keep on returning
  for (let i = 0; i < smallCaps.length; i++){
    if(target.indexOf(smallCaps[i]) < 0);
    return true; 

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

Challenge Information:

Basic Algorithm Scripting - Mutations

You haven’t added a code block to execute when this condition is true.

1 Like

Hello, Thank you for letting me know, in that condition sir should I add code to define “target.indexof” sorry I’m confuse with the error

Your code in the condition is syntactically fine. Can you explain what you want to accomplish with the loop using words?

1 Like

I’m confused about using this “indexOf(parameters) < num”

I want to mutate the constant variables while getting their indexes by using indexOf function

Forget about code right now, explain the instructions for what you want to do in plain English.

For example:

I would say “for each letter in the first word, I will ____________”. Now you fill in the blank.

I should sort them in lowcaps/uppercase

Remember the goal is this:

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

I don’t think you need to sort the letters to accomplish the above task.

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