function mutation(arr) {
let arr1 = arr[0].toLowerCase().split("");
let arr2 = arr[1].toLowerCase().split("");
for (let i = 0; i < arr[0].length; i++){
if (arr1.indexOf(arr2[i]) == -1){
console.log("not found");
} else { console.log(" found"); }
}
}
mutation(["hello", "hey"]);
link : https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations/
How return the Boolean from function to pass the quiz ?
You can have more than 1 return statement in a function, actually you can have as many return statements as you want/need. But keep in mind that the first to get executed will break the function and return the assigned value.
In your case you can define a return statement returning a certain Boolean value in the if statement to be executed when the Boolean expression associated with it true and a return statement returning the opposite value in the else statement.
if(true){
//your code
return true
} else {
//your code
return false;
}
You can also solve this with the ternary operator