Create Strings using Template Literals2

Tell us what’s happening:
Where is the wrong?Please tell me

Your code so far


const result = {
  success: ["max-length", "no-amd", "prefer-arrow-functions"],
  failure: ["no-var", "var-on-top", "linebreak"],
  skipped: ["id-blacklist", "no-dup-keys"]
};
function makeList(arr) {
  "use strict";

  // change code below this line
  const resultDisplayArray = [];
  arr.map(val => resultDisplayArray.push('<li class="text-warning">${val}</li>'))
  // change code above this line

  return resultDisplayArray;
}
/**
 * makeList(result.failure) should return:
 * [ <li class="text-warning">no-var</li>,
 *   <li class="text-warning">var-on-top</li>, 
 *   <li class="text-warning">linebreak</li> ]
 **/
const resultDisplayArray = 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/67.0.3396.99 Safari/537.36.

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

make sure you are using the backticks not regular quotes
backticks look like this:
`
not like this

also note there is a known bug in this challenge. So you can skip it for now if you like or fix the code first then when the challenge is also fixed you can come back and pass it.

and what can i do for this code to change the code?

just change your quotes to backticks
then you should only see one error when you run the tests.
the last error is from the FCC challenge and you can skip this challenge for now (just go back to the curriculum page and move to the next item in the list)

Which is of quotes i can use because i don’t know

Consider using backtick symbol on your keyboard. (the backtick is usually the key below esc key.
Change to this.

arr.map(val =>; resultDisplayArray.push(`li class="text-warning">${val}</li>`))

const result = {
success: [“max-length”, “no-amd”, “prefer-arrow-functions”],
failure: [“no-var”, “var-on-top”, “linebreak”],
skipped: [“id-blacklist”, “no-dup-keys”]
};
function makeList(arr) {
“use strict”;

// change code below this line
arr.map(val => resultDisplayArray.push(<li class=“text-warning”>${val}</li>)) // change code above this line

return resultDisplayArray;
}
/**

  • makeList(result.failure) should return:
  • [
  • no-var
  • ,
  • var-on-top
  • ,
  • linebreak
  • ]

**/
const resultDisplayArray = makeList(result.failure);

It isn’t right because it has red underline in some words

Im sorry. This is my first post here. still figuring out how to quote and reply to posts properly. I guess what i posted earlier didnt display as I wanted.

ok don’t worry this is your first post here

You are using template strings here. The rule is to enclose the list tag inside backtick symbol. it seems like you enclosed it inside single quote. Note that is different from ’ ’

I hope this helps.

Thanks. this was very helpful. And how did you make the gif animation. id love know. it might come in handy someday.

Hi Klaudia

here’s a picture of a keyboard. The green button is the one that has the backtick. Don’t use the red button which is a single quote.

2 Likes

Omg this is right but i have one more:
Template strings were used
and the code is:
const result = {
success: [“max-length”, “no-amd”, “prefer-arrow-functions”],
failure: [“no-var”, “var-on-top”, “linebreak”],
skipped: [“id-blacklist”, “no-dup-keys”]
};
function makeList(arr) {
“use strict”;

// change code below this line
const resultDisplayArray = [];
arr.map(val => resultDisplayArray.push(<li class="text-warning">${val}</li>))
// change code above this line

return resultDisplayArray;
}
/**

  • makeList(result.failure) should return:
  • [
  • no-var
  • ,
  • var-on-top
  • ,
  • linebreak
  • ]

**/
const resultDisplayArray = makeList(result.failure);

here is a link that describes how to use map

You are still using yours incorrectly.