Create Strings using Template Literals help please

I’m finding this ES6 section really confusing. Does anyone know why this won’t work ?

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 myArr = [];
  for(let i = 0 ; i < arr.length ; i++){
   myArr.push(`<li class="text-warning">${arr[i]}</li>`);
  const resultDisplayArray = myArr;
  // 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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:

This is a bit weird. Your code is using template strings correctly.

I’ve tested both your code and completed it using .map and logged both arrays. Their output is slightly different, so maybe it’s a bug in the FCC tests. If you look in the screenshot below, the outputs are the same and are correct, but look slightly different.


We’ll flag a mod and see if they can investigate more. In the meantime, try using .map instead of the for-loop like you’re doing and see if that fixes it.

Let me know if you have more trouble.

1 Like

ah thanks for getting back. I thought I butchered it somehow. I will do it with .map like you said . thanks!

1 Like