Eghe
November 29, 2018, 4:15pm
1
Tell us what’s happening:
please why this error?
resultDisplayArray is the desired output.
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.map(arr => `<li class="text-warning">${arr[0]}</li><li class="text-warning">${arr[1]}</li><li class="text-warning">${arr[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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3223.0 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals
Eghe
November 29, 2018, 4:18pm
2
Tell us what’s happening:
why this error please?
resultDisplayArray is the desired output.
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 = [];
for ( var x = 0; x < arr.length; x++) {
resultDisplayArray.push(`<li class = "text-warning">${arr[x]}</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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3223.0 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals
Please do not create multiple topics for the same issue. You can add to or edit your original thread. I have merged your two topics.
Make sure you are using template literals.
Instead of traditional single quotes ’ use backticks `
First Case - be careful when using the map method because it allows you the option to pass 3 arguments (element, index, whole array). In your case, you are trying to pass it the whole array as an argument, however it is treating it as if you are passing an element of the array (e.g. only “no-var”). So, when you are using arr[0], arr[1], you access just the separate letters from the “no-var” element.
Second Case - I think it is just a spacing issue. There shouldn’t be any spaces in the
li class=“text-warning”.
1 Like
Eghe
November 30, 2018, 4:29pm
7
this was so helpful, thanks… it ended up just a spacing issue, you can imagine lol