Create Strings using Template Literals [help!]

Create Strings using Template Literals [help!]
0

#1

**Tell us what’s happening:
Don’t know how to solve this problem. …

I think I understand what the problem is asking but I’m confused on how to get a solution - particularly the “each entry of the result object’s failure array”

So I’m supposed to pass the contents of result.failure through a string using backticks, right? And just to add to the confusion we are going to pass the contents of this array through a string that also happens to be HTML.

Cool.

So I’m guessing it will look something like

const resultDisplayArray = <li class = "text-warning">${result.falure}</li>

So I typically start the problems this way: what do I know, what do I think that would look like, what does the example look like, what’s different from the example and the problem. I think the issue is the Array part is throwing me off.

Any help appreciated.

This is the problem before any changes are made:


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 = null;
  // 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/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals


#2

If you look at the very bottom line (seen below), result.failure is passed as an argument to to makeList function. In case you did not notice, result.failure is an array, which is why the single parameter of makeList is named arr. You should be referencing arr inside the makeList function is such a way as to create a new array with arr’s values as the inner text li elements.

const resultDisplayArray = makeList(result.failure);

Think about how you could use a high order function like Array.prototype.map to create this new array of string li elements.