Create Strings using Template Literals - I got stucked on this challenge

Tell us what’s happening:
I am stuck with this problem because it doesn’t pass and to me, it looks right. Please let me know if there is anything I am missing or omitting. Thanks.

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";

  // change code below this line
  const resultDisplayArray = `[<li class="text-warning>${result.failure[0]}</li>,
                               <li class="text-warning>${result.failure[1]}</li>,
                               <li class="text-warning>${result.failure[2]}</li>]`;
  // change code above this line

  return resultDisplayArray;
 * makeList(result.failure) should return:
 * [ <li class="text-warning">no-var</li>,
 *   <li class="text-warning">var-on-top</li>, 
 *   <li class="text-warning">linebreak</li> ]
const resultDisplayArray = makeList(result.failure);

Your browser information:

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

Link to the challenge:

Hi mohamudolow,

  1. You need to return an array. Not a string.
  2. function makeList(arr) passes this parameter result.failure. So instead of result.failure it should have been arr.

I solved this using the map function. I tried using a for loop and push function. I’m getting the same output but the test “Template strings were used” wouldn’t pass.

function makeList(arr) {
  "use strict";

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

If you (we) couldn’t find the answer, just use the map function for now.

Happy coding!

There are two issues with your solution.

First, you are not returning an array. Your entire return value is wrapped in backticks so it is one long string - you need to return an array of strings.

// one long string
`[one, two, three, four]`

// array of strings
[`one`,`two`,`three`, `four`]

Second, you left the second quotation mark off after the class attributes

<li class="text-warning>${result.failure[0]}</li>

right after warning.

Correct those things and your solution should pass.

Ideally your solution would loop through each of the failure conditions to create the resulting array. That way if an additional failure condition were added in the future the code would accommodate that change. Consider what would happen if at some point a fourth failure condition were added or if one were removed.