Isabel
September 14, 2020, 7:26pm
1
Tell us what’s happening:
Please help I can’t tell what am I doing wrong with this code.
Your code so far
const result = {
success: ["max-length", "no-amd", "prefer-arrow-functions"],
failure: ["no-var", "var-on-top", "linebreak"],
skipped: ["no-extra-semi", "no-dup-keys"]
};
function makeList(arr) {
// Only change code below this line
const failureItems = arr.map(item => '<li class="text-warning">${item}</li>');
// Only change code above this line
return failureItems;
}
const failuresList = 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/85.0.4183.102 Safari/537.36
.
Challenge: Create Strings using Template Literals
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Hi! Try using backticks ` instead of single quotes on the line:
`<li class="text-warning">${item}</li>`
Isabel
September 14, 2020, 9:30pm
3
thank you for your help, i did try the backticks but it does not work. Any other suggestions.
I tried running the tests on freeCodeCamp with the backticks and it passed all four tests. Which test does it fail for you?
const failureItems = arr.map(item => `<li class="text-warning">${item}</li>`);
Isabel
September 15, 2020, 1:30pm
5
this two are not passing
failuresList
should be equal to the specified output.
Template strings and expression interpolation should be used.
ilenia
September 15, 2020, 2:26pm
6
what have you tried? what’s your new code?
Isabel
September 15, 2020, 2:32pm
7
I also try the + sign but it doesn’t not work.
const failureItems = arr.map(item => ‘
’ +${ item } +’ ’);
As SimonRhe pointed out above, your code has single quotes and needs to have the backtick. I ran your code as you posted it and it returns the errors you listed. The backtick ( ` ) key on my keyboard is above the TAB key and below the ESC key. The single quote ( ’ ) key is to the left of the ENTER key and is on the same key as the double quotes ( " ). Replacing the single quotes in your code with the backtick will pass the tests as already mentioned by Simon.
I have placed a red circle around the correct key in the image below.
1 Like
Isabel
September 16, 2020, 7:41pm
9
NorthDecoder, I appreciate your help, so I reset the entire code, use the backtick key and it did work it pass, thank you so much for your help.