Used includes() instead of indexof()

Tell us what’s happening:
My code works, but I like to see the solutions given because they are usually much more concise. I guess I just want confirmation that using includes() is appropriate. Is there a reason that index() is a better choice?

Your code so far

function mutation(arr) {
// To ignore case, change all to lowercase.
arr[0] = arr[0].toLowerCase();
arr[1] = arr[1].toLowerCase();

// Declare result variable as an array.
// Each include() result will be added to
// the result array.
let result = []

// Looping through each letter of the second word,
// check if each is included in the first word.
for (let i=0; i<arr[1].length; i++) {
  result[i] = arr[0].includes(arr[1][i]);

// See if any of the results where false.
if (result.includes(false)) {
  console.log('One of the results is false.')
  return false;
console.log('All of the results were true.')
return true;

mutation(["hello", "neo"]);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15.

Challenge: Mutations

Link to the challenge:

1 Like