Help me !CAN'T solve this problem(

Tell us what’s happening:

Your code so far


const result = {
success: ["max-length", "no-amd", "prefer-arrow-functions"],
failure: ["no-var", "var-on-top", "linebreak"],
skipped: ["id-blacklist", "no-dup-keys"]
};
function makeList(arr) {
"use strict";

// Only change code below this line
const resultDisplayArray = [];
for (let i = 0; i < arr.length; i++){
  return resultDisplayArray.push(`<li class="text-warning">${arr[i]}</li>`);
}
// Only change code above this line

return resultDisplayArray;
}

const resultDisplayArray = makeList(result.failure);

Your browser information:

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

Challenge: Create Strings using Template Literals

Link to the challenge:

Your code logic is great :slight_smile:

You just need to remove the return you have before you push to the array.

They have already provided a return statement for you, and the way your return was functioning it was returning the array before it was complete with the information you want in it.

2 Likes

Here, you don’t want to return to push the string, because if you return it, it’s just gonna return saying that, hey I pushed it, but it didn’t actually modify anything. So try to remove the return on your push.

1 Like

Thank u so much :heart_eyes: :heart_eyes: :heart_eyes: :heart_eyes:

1 Like

I’m so grateful for the explanation!!! :kissing_heart: :kissing_heart: :kissing_heart:

1 Like

The push method’s return value is the length of the array after the new element has been pushed, so you would be returning the value 1 and then the function is exited.

1 Like

Thank u so much :blush: :blush: :blush:

const resultDisplayArray = ;

for(let i = 0; i < arr.length; i++){

 let msg = `<li class="text-warning">${arr[i]}</li>`

  resultDisplayArray.push(msg);

}

/just remove return keyword from your code!/

1 Like

Thank u :dizzy: :smiley_cat: :smiley_cat: :smiley_cat: