ES6 - Create Strings using Template Literals

Tell us what’s happening:
I’m stuck!!
where did I done the mistake in this code??
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 = `[<li class="text-warning">${result.failure[0]}</li>
  <li class="text-warning">${result.failure[1]}</li>
  <li class="text-warning">${result.failure[2]}</li>]`;
  // Only change code above this line

  return failureItems;
}

const failuresList = makeList(result.failure);
console.log(failuresList)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: ES6 - Create Strings using Template Literals

Link to the challenge:

i just took 1 second look and didn’t notice that you have an iterator in the function yet?
The exercise says:

Use an iterator method (any kind of loop)

So that would be one thing I think you should start with.

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 = ;
result.success.forEach((item) => {
failureItems.push(item);
});
// Only change code above this line

return failureItems;
}

const failuresList = makeList(result.failure);

tried using this also
it’s not working out!!

1 Like

In what way is it not working out?
What result were you expecting the code that you wrote to give for example? What did it actually create?

1 Like

You need to return array of strings from given as argument array (arr), but wrapped in li tag, not just strings themselves. That’s why you need backticks and ${}, this is easiest way.

Try this:

  // Only change code below this line
Mod edit: solution redacted 
  // Only change code above this line
1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

I thought I explained the solution, but ok

1 Like

hello, try this.
function makeList(arr) {
// Only change code below this line
const failureItems = ;
for (let i = 0; i < arr.lenght; i++){
failureItems.push('

  • ${result.failure[i]}
  • ');
    };
    // Only change code above this line

    return failureItems;
    }

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