ES6 - Create Strings using Template Literals

Tell us what’s happening:

Need a little help hehe.

Managed to get the specified output but can’t seem to get this right :

failuresList should be an array containing result failure messages.

I’ve tried other ways and then I only get the value of failure without the li elements. What am I doing wrong?

Your code so far

const result = {
  success: ["max-length", "no-amd", "prefer-arrow-functions"],
  failure: ["no-var", "var-on-top", "linebreak"],
  skipped: ["no-extra-semi", "no-dup-keys"]
};
function makeList(arr) {
  // Only change code below this line

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

  return failureItems;
}

const failuresList = makeList(result.failure);

console.log(result.failure);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

ES6 - Create Strings using Template Literals

Easy stuff first :slightly_smiling_face:

I don’t see an exclamation point in the example output. I think you need to get rid of that.

Somewhat harder stuff.

You are returning an array named failureItems. So I’m guessing you want that array to hold the messages you are creating. I don’t see where you are doing that. Are you sure you are modifying the correct array?

Finally, can you explain why you are using the += operator to set the value of an item in the array?

I don’t know what I was thinking with +=, trials and errors I guess hehe.

This is my new code : function makeList(arr) {
// Only change code below this line

const failureItems = (result.failure); {
for (let i = 0; i < arr.length; i++) {
arr[i] = (<li class="text-warning">${arr[i]}</li>);

}

}
// Only change code above this line

return failureItems;
}

const failuresList = makeList(result.failure);

console.log(failuresList); and when I console.log failuresList I get this:

[ ‘

  • no-var
  • ’,
  • var-on-top
  • ’,
  • linebreak
  • ’ ]

    Which seems to be the right thing, but still I’m getting this message back :
    failuresList should be equal to the specified output.

    From what I’m seeing it’s equal to it. How am I thinking wrong?

    I’ve solved it hehe ty anyways

    1 Like

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