Template Literals IN ES6

I stuck please someone explain this challenge for me

  **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 = [];
// Only change code above this line

return failureItems;
}

const failuresList = 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/101.0.4951.67 Safari/537.36

Challenge: Create Strings using Template Literals

Link to the challenge:

  • The result.failure array is passed to the function.

  • Loop the array and for each array element (strings) create a template literal that is a li element using the currently iterated element as the text content.

  • Return the new array of template literal strings.

Example code:

const names = ['Alice', 'Bob', 'Tiff'];

const namesInsideH2 = names.map(name => (`<h2 class="user-name">${name}</h2>`));

console.log(namesInsideH2);
/* 
[ '<h2 class="user-name">Alice</h2>',
  '<h2 class="user-name">Bob</h2>',
  '<h2 class="user-name">Tiff</h2>' ]
*/

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