I'm so close: Create strings using template literals

Tell us what’s happening:
My code creates 3 arrays instead of one array.

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 (var i=0; i < result.failure.length; i++) {
console.log([`<li class="text-warning"> ${result.failure[i]}`])
}

// Only change code above this line

return resultDisplayArray;
}

const resultDisplayArray = makeList(result.failure);

Your browser information:

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

Challenge: Create Strings using Template Literals

Link to the challenge:

You’ve hardcoded in your solution, your need to use the arr parameter given in the function otherwise your function would fail given either option of success or skipped.

You need to push each iteration to the array with resultDisplayArray.push()

But honestly even after doing these things to your code I still got 3 results as well. No idea what’s happening so i just re wrote it from scratch. Here are 2 solutions the first is basically your code with the required changes.

Hope this helps!

for (let i = 0; i < arr.length; i++) {
      resultDisplayArray.push(`<li class="text-warning">${arr[i]}</li>`)
    }
let resultDisplayArray = [];
  arr.forEach(elem => {
    resultDisplayArray.push(`<li class="text-warning">${elem}</li>`);
  })```

Thanks for your help. I got it now.