Create Strings using Template Literals https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals

Create Strings using Template Literals https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals
0

#1

Tell us what’s happening:
is this code wrong?

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 = [];
  var i = 0;
  while(i < arr.lenght) {
    resultDisplayArray[i] = `<li class="text-warning">${arr[i]}</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/69.0.3497.100 Safari/537.36.

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


#2

Which tests aren’t passing?


#3

resultDisplayArray is an array containing result failure messages.


#4

while(i < arr.lenght


#5

already corrected arr.length and still have the same problem.


#6

You need to change i during each iteration of the while loop or else i will be 0 forever.

Also, resultDisplayArray should be a string and not an array.


#7

@freecodecampnewemail,

Hey bud, I just solved this challenge(with the help of other campers of course). you can check how I solved it here: What am I doing wrong: ES6: Create Strings using Template Literals


#8

how i can change i during each iteration?


#9

You need to increment it by one.


#10

I can’t imagine how i missed it.
Thank you