Create Strings using Template Literals

My 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++){
    const failureItems = `<li class="text-warning">${arr[i]}</li>`;
  }
  // Only change code above this line

  return failureItems;
}

const failuresList = makeList(result.failure);

I’m failing to pass one of the tests:

  • Failed:failuresList should be an array containing result failure messages.

  • Passed:failuresList should be equal to the specified output.

  • Passed:Template strings and expression interpolation should be used.

  • Passed:An iterator should be used.

Could you post a link to the challenge you’re trying to pass please?
Also, when posting code, please enclose it within two sets of triple backticks (```) so that it displays more clearly. You can use CTRL+e to create these backticks automatically and then paste your code in-between.

Here is the link to the challenge. I’ll keen in mind the format for posting code in the future.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Take a close look at this line here

You don’t need to create another variable inside this for loop.
The goal is to add the list items to the array.
One way to fix this would be to use an array method that adds elements to the end of the array.

used .push and it passed. Thanks,