Basic Algorithm Scripting - Mutations

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

function mutation(arr) {
let  faristWord =arr[0].toLowerCase().split('');
let  secondeWord =arr[1].toLowerCase().split('');
for (let i=0;i < secondeWord.length;i++);{
if(faristWord.indexOf(secondeWord[i]) == - 1){
    return false;
  return true;

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

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; Infinix X652) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Mobile Safari/537.36

Challenge: Basic Algorithm Scripting - Mutations

Link to the challenge:

Hi there, did you have a question?

where is the end of a line of code given that the line of code is a loop?

Remove the semicolon ; at the end.

For loops do not need semi-colons to end them. They always look like this

for ([initialExpression]; [conditionExpression]; [incrementExpression]) {

you’re right

function mutation(arr) {let  faristWord =arr[0].toLowerCase().split('');let  secondeWord =arr[1].toLowerCase().split('');for (let i=0;i < secondeWord.length;i++){if(faristWord.indexOf(secondeWord[i]) == - 1){return false;}}return true;}{console.log(mutation(["hello", "hey"]))}console.log("there!")

is it that any closing curly bracket is by automatically a line break, like ; by default?

Not really?
The semicolon is needed for other constructs, just not for for loops.

oh. it’s just i tested at end of my ‘line’ of code in different construct. seems fine.

don’t think of the curly brace as a “end of line” character.
it is more like something that opens a new scope in the code.
I wouldn’t worry about this now until you understand more javascript.

1 Like

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