Basic Coding Challenge: Mutations_How can I use arr.map to modify casing?

I am working on the Mutations problem on https://www.freecodecamp.org/challenges/mutations. For this challenge, we need to return true if the string in the first element of an array contains all of the letters of the string in the second element of the array. Case should be ignored.

To deal with case, I would like to put all letters in lowercase using arr.map. So far, I have been unsuccessful with this. I’ve tried

function mutation(arr) {
arr.map(function(x){
    x.toLowerCase();
  });
...
mutation(["Bye", "by"]);

The console.log test put out [ 'Bye', 'by' ], showing that the array had not been modified. When I tried with

function mutation(arr) {
var arrLowerCase = [];
  for (var i = 0; i < arr.length; i++) {
    arrLowerCase.push(arr[i].toLowerCase());
  }
  arrLowerCase;
...
mutation(["Bye", "by"]);

the console.log test churned out [ 'bye', 'by' ] showing that uppercase letters had been modified and providing the desired output.

Is there a way to use arr.map to change casing in arrays as well? Thank you in advance.

Arr map needs a return value. Currently it looks like you’re not returning anything. Try something like this.

function lowerCase(arr){
  let ans = arr.map(function(word){
    return word.toLowerCase()
  }
  return ans;
}
1 Like

The code is working now!