Create Strings using Template Literals-

Tell us what’s happening:
Why my this code give me an error !

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 = arr.forEach(function(i){
    console.log([`<li class="text-warning">${i}<\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);

You have some issues issues.

  1. Your closing li tag is not the correct syntax.
  2. forEach does not return a value.
  3. console.log() only displays values to the console.

Suggestions:

  1. Look into using the map method.
  2. Make sure you are creating an array of strings and not an array of arrays
1 Like