I'm having trouble with Mutations

Tell us what’s happening:
I’m getting the length of them and using them for the if statement.
It’s not making them lowercase, why?

   **Your code so far**

function mutation(arr) {
for (let i = 0; i < arr.length; i++) {
  arr[i].toLowerCase();
}
let a = arr[0];
let b = arr[1];
var x = 0;
var y = 0;
x = a.length - 1;
y = b.length - 1;
if (a[0] == b[0] && a[x] == b[y]) {
 return true;
}
return false;
}

mutation(["hello", "hey"]);
console.log(mutation(["hello", "hey"]));
   **Your browser information:**

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

Challenge: Mutations

Link to the challenge:

String.prototype.toLowerCase() Return value: A new string representing the calling string converted to lower case. mdn

It’s not changing array values

1 Like
function mutation(arr) {
 var c = arr[0];
 var d = arr[1];
 c.toLowerCase();
 d.toLowerCase();
 
 var x = 0;
 var y = 0;
 x = c.length - 1;
 y = d.length - 1;
 console.log(c[x])
 console.log(d[y])
if (c[0] == d[0] && c[x] == d[y]) {
  return true;
}
return false;
}

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

Why did this code not work? I made it to a string now.

Just realised that (the first string needs to have all the values that the second has).

this is not changing the strings

you are just checking first and last letter, you need to check them all

2 Likes

I misunderstood the challenge. Thanks for help.

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