Template string

Tell us what’s happening:

What else should I do in the code?
I have already created a multiline string.
So what does it mean by " template string were used"?

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/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

Hi,
You hard coded the answer.
The array result.failure has already been passed into the function makeList as an argument. You should use the function parameter instead of result.failure[0] . :slight_smile:

1 Like

till the result shows that template string were used.

It means that your answer is printing the result <li class="text-warning">no-var</li>, but it is not being flexibile to print anything else.
So, you need to change:
<li class="text-warning">${result.failure[0]}</li>
to
<li class="text-warning">${arr[0]}</li>.

1 Like

Thanks. I got it…One more question- Is it a wrong process ? I just asked for help whenever I stuck on something and without any farther trying I just asked it on the forum. Feeling guilty sometime.

This is very subjective to opinion.
I think that as long as you’re not just after the easy answers, then it is ok to ask directly in the forums.
Just make sure to fully understand the problem and learn new stuff along the way. ^^

1 Like