Creating Strings with Template Literals

Tell us what’s happening:
I’ve tried hard not to have to ask for help, but hours of trial and error have got me nowhere. I’m going to have to skip this and move on. I’m using a Pixel Chromebook [2015] and its Chrome browser, but not in developer mode. I’ve read many posts from others who, like me, simply can’t get to pass this challenge. I’ve got my code to work OK on my codepen worksheet, but not here. It’s frankly quite disheartening!

  **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 = [];
for (let i = 0; i < arr.length; i++) {
  failureItems.push(`<li class = "text-warning">${arr[i]}</li>`);
// Only change code above this line

return failureItems;

const failuresList = makeList(result.failure);
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 13729.56.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.95 Safari/537.36.

Challenge: Create Strings using Template Literals

Link to the challenge:

does this match exactly the required output?

I’ve tried hard not to have to ask for help, but hours of trial and error have got me nowhere.

Well, maybe next time don’t wait so long. [wink]

The description says to return this:

  '<li class="text-warning">no-var</li>',
  '<li class="text-warning">var-on-top</li>',
  '<li class="text-warning">linebreak</li>'

You are returning this:

[ '<li class = "text-warning">no-var</li>',
  '<li class = "text-warning">var-on-top</li>',
  '<li class = "text-warning">linebreak</li>' ]

Notice the difference? There are two extra spaces in the strings you are returning. In a normal HTML element, those may not matter, but these are being stored as strings and the test is very specific about what strings need to be returned.

When I fix that (in the string literal you are pushing, by removing those two spaces), the test passes for me.

I was grateful and very much encouraged by two prompt replies, for which many thanks!
I’ve removed the offending spaces and my code has now succeeded. What a relief!

Well, we can’t always guarantee it will be prompt - we’re a bunch of volunteers here - but we try to help. I’m glad you got it worked out. Have fun on the next challenge.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.