Create Strings using Template Literals2

Create Strings using Template Literals2
0.0 0

#1

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


#2

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.


#3

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


#4

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)


#5

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


#6

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>`))

#7

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


#8

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.


#9

You should read about how to properly use the map method. Map will return a new array, so there is no reason to create an empty array first and then use push. And of course as @hbar1st already mentioned, you need to surround the string with backticks instead of straight single quotes.


#10

ok don’t worry this is your first post here


#11

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.


#12

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a 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.


#13

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


#14

There are many online tools you can use which will convert a video into an animated gif. Just search for “convert video to animated gif” and you will find many ways to do it.


#15

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.


#16

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);


#17

here is a link that describes how to use map

You are still using yours incorrectly.