Tell us what’s happening:
Can’t understand why in this task it tells me that “!Template strings were used” if I do use them,
what could be wrong?
Thank you!
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">${arr[0]}</li>`,
`<li class="text-warning">${arr[1]}</li>`,
`<li class="text-warning">${arr[2]}</li>`]= arr;
// 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.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals
I am having a similar problem with the following,
// change code below this line
const resultDisplayArray = [];
for(let i = 0; i < arr.length; i++){
resultDisplayArray[i] = `<li class="text-warning">${arr[i]}</li>`;
}
// change code above this line
From what I’ve read the use of bracket notation here doesn’t work with the code checker, which is slightly frustrating.
ok, will leave it for a while, thanks though
I got it to pass after some work. I utilized array mapping to create a new array based on arr. Try reading up on it here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Basically, you can create a new array by passing a function to the components of another array (leaving that original one intact). Some basic syntax to get started with, you can use whatever you want for the variable name, but to get the string literal to work there should be a ${variable} with no indexes inside the literal.
arr.map(variable=>{function here});
Let me know if you have still having trouble, it took me some time to figure out after reading other posts
Yes, it works! Cool!
But they should have given more specifics for this particular task, thinking as a programmer it is very important, but we are learning template literals here))))