Create Strings using Template Literals. not working

Create Strings using Template Literals. not working
0.0 0

#1

Tell us what’s happening:
Code keeps giving me this three errors:
resultDisplayArray is a list containing result failure messages.
makeList(…).every is not a function
Invalid regular expression flags

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 = **`[ <li class="text-warning"> ${arr[0]}</li>,**
**                                <li class="text-warning"> ${arr[1]}</li>,**
**                                <li class="text-warning"> ${arr[2]}</li>]`;**//my code answer
  // 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);

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


#2

The tests for this challenge will still not allow you to pass even with a correct solution. However, your solution is still not correct, because your resultDisplayArray variable is a single string instead of an array of strings.


#3

i dont get how i am supposed to make it an array of strings if i am to put all of it inside those backtick quotes


#4

What if I asked you to create an array of strings without using backticks? You would write:

['string1', 'string2', 'string3']

The backticks are just another way of specifying the start and end of a string with the option of add some JavaScript code within the ${ } part. The array (the [ ]) can not have quotes or backticks around it, or it is no longer an array.


#5

oh i tried something similar but instead i did [ ’ string1, string 2, string 3 '] instead
But that makes more sense


#6

That is an array with a single string. You want an array with 3 strings.