Another Bug in Create Strings using Template Literals

I can pass the first and the last test, I do not pass my second test.

It says 'resultDisplayArray is the desired output’

my code so far

function makeList(arr) {
"use strict"
const resultDisplayArray = arr.map(x => '<li class="text-warning">$(x)</li>');
return resultDisplayArray;
}

Anyone else facing similar issues?

It is hard to tell from the code you posted but it appears that you might have used the single quote character to create your template literal. Template literals need to be wrapped with the backtick character (upper left qwerty keyboard same key as ~) that looks similar to single quote. ` vs '

Speaking of backticks, if you wrap your code in three backticks (or use the </> button above) your code will format properly in the post.

```  //three backticks
 // code inside
 function someFunction(arr){
   do stuff;
}
```  //three more backticks

Or you can use the “Ask for Help” button on the challenge page. That will open a post with your code properly formatted AND include a link back to the challenge so others can read the problem too.

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

Ok, will do…

I’ll reformat my code and post it here. Basically, I have got the part about “do some stuff”, I am good there. But I am not passing the second test which says the output should be the resultDisplayArray

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

Perfect. Now I can see. You are very close.

OK - so you are not using backtick to surround your template literal. Single quote will not work here.

From challenge: Firstly, the example uses backticks ( ``` ), not quotes ( ' or " ), to wrap the string.

'<li class="text-warning">$(x)</li>'

vs

`<li class="text-warning">$(x)</li>`

image


…and there is something not quite right about your syntax for interpolation. Do you see the difference?

From challenge: The ${variable} syntax used above is a placeholder.

Thanks @DanCouper for editing and @alhazen1…yeah the backtick one was kind of a bummer…I am LOL thinking of how much trouble can a backtick cause.

Yes, I see the difference…${x} not $(x)

3 Likes