I have been looking for this for literally 3 hours straight… because I missed 1 empty space… thats frustrating haha
I literally copied the code from this example, reset the exercise. Still not working…
In that post we are talking about the use case, there are so many ways to achieve similar results.
here is the same code
Sorry, I was a little but frustrated yesterday night and oversaw that the “=” is missing.
Thanks a lot for clarifying!
Towards the end you have instead of
Yes, I know. I’ve already solved it. See some posts above. Thanks anyway!
Just want to point out that I initially used your exact solution method with the exception of using a for-loop instead of Array.prototype.map(), and did not pass all tests.
Using a for loop does not pass the template strings test, and console.log() returns:
(3) […]
0: "<li class=\"text-warning\">no-var</li>"
1: "<li class=\"text-warning\">var-on-top</li>"
2: "<li class=\"text-warning\">linebreak</li>"
length: 3
Using Array.prototype.map() passes all tests and returns:
(3) […]
0: "<li class=\"text-warning\">no-var</li>"
1: "<li class=\"text-warning\">var-on-top</li>"
2: "<li class=\"text-warning\">linebreak</li>"
length: 3
Same thing. In both cases, template strings are used. But one passes all tests and one does not.
Thank you, it helped me to understand the challenge
By the way I found a way to shorten the solution :
const resultDisplayArray = arr.map(x => <li class="text-warning">${x}</li>
);
This guys is explaining map function super nicely .
Check it out!
And I must say his whole series about functional programing are great.
Hi There,
I’m stuck on this exercise and can’t validate my answer. Thought I got it, but I got an “invalid regular expression flag l” when passing the test. Would someone happen to know why?!
Here is my answer
const resultDisplayArray = arr.map(val => `<li class="text-warning">${val}</li>`);
Thank you!
Oh ok thank you I thought it was resolved and it seems that people passed the test. Can you tell me if my code is ok and should pass the test?
It looks like the new fcc version as a lot of bugs, it makes it hard to know when you are right or wrong
Thank you
OK, thanks a lot Randell!
I tried with …
const resultDisplayArray=arr.map((val) => <li class="text-warning">${val}</li>
);
Got that String Template Not Used …
I thought there must be a bug… So i went to the forum and luckily found this thread … seems like the bug is still there … Or am i doing something wrong … help required !!!
I tried the same thing too:
const resultDisplayArray = arr.map((element) => <li class="text-warning"> ${element} </li>
);
And got 2 errors:
resultDisplayArray is the desired output.
Invalid escape in identifier: ‘’
Right now the quote " in our ...
popped a problem. The results in Google console look like this:
["<li class=\“text-warning\”>no-var","<li class=\“text-warning\”>var-on-top","<li class=\“text-warning\”>linebreak"]
I noticed the backslash \ included in the printed result, right before the quote ". The backslash is there when I did and did not included in my code. Anyone know how to solve this?
Thanks a lot.
Here you have not used template literals…your HTML code should be inside ' …yourCode…'.
my attempts
//1st
const resultDisplayArray =[];
arr.map((x) =>{return resultDisplayArray.push(<li class="text-warning">${x}</li>
);});
//works on console not in fcc, error : " Invalid regular expression flags ".
//2nd
const resultDisplayArray = arr.map(x =><li class="text-warning">${x}</li>
);
//same works on console not in fcc, error : " Invalid regular expression flags ".
@thevenice The second solution is close. You would still need to wrap your string in back ticks though.
@vandao288 Same for you. Your solution is close but to be template literal would have to be wrapped in back ticks.
Unfortunately there is still a bug in the test for this challenge so there is no way to complete it at this time.
If you want to take your solution for a test drive…
Back ticks aren’t able to display in here comments and both the solutions worked on console lemme give you link because this section doesn’t allowing me to post more than 1 picture.
Thank you guys a lot, I didn’t expect such fast responses.
@thevenice : you’re right about back ticks aren’t able to display here in comments. About console, I ran it in Google Developer’s Tool but it does display backslash \ before quote ". Hence it is somehow not exactly what we expect from the answer. I just wonder if there is away to get quote " displayed properly within a backtick string.
Here I attach the google console screen for it. I’ve got the same thing on repl.it too.