Create Strings using Template Literals -failureList

Tell us what’s happening:
Describe your issue in detail here.
Hi Everyone, I’m not sure what Im doing wrong , I can not pass this test failuresList should be equal to the specified output.
But it works in my console - not sure what I am missing?
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Create Strings using Template Literals

Link to the challenge:

I would suggest you add a console.log just before the return statement showing you what is actually being returned. Remember, the returned output must be exactly the same as what the instructions are asking for.

Thank you for your help but I think Im still missing something. The only thing I can think of is that it prints the array twice when I console.log it - which Im not sure why its doing that Otherwise it prints exactly what the challenge is asking for.

This is what the output should be:

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

This is your output:

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

Do you see the difference?

1 Like

It’s because you have spaces between your class and your text-warning. Remove it and it should work.

1 Like

Yes I do thank you! I thought that could be the problem but refused to believe it was that simple - I have a bad habit of doing that…Thanks again

1 Like

Thank you! I’m always second guessing my self - thought that could be it

I know what you mean. When working with computers it sometimes seems like every issue is very complicated when really it’s just a simple typo :slight_smile:

In general, to save yourself grief with the FCC tests, always remember:

  • Do not change anything other than what the instructions ask you to change.
  • Make sure your changes do exactly what the instructions are asking for, right down to each individual character.
1 Like

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