Tell us what’s happening:
Describe your issue in detail here.
The solution that I did is giving me this result
[ 'no-var',
'var-on-top',
'linebreak',
'no-var',
'var-on-top',
'linebreak',
'no-var',
'var-on-top',
'linebreak' ]
when I used the forEach method inside the for in loop. It was incrementing all the values of failure to every original value of failure. Basically, it is the value of
("no-var", )
'no-var',
'var-on-top',
'linebreak',
("var-on-top")
'no-var',
'var-on-top',
'linebreak',
( "linebreak")
'no-var',
'var-on-top',
'linebreak' ]
I’ve seen the other solutions but is it possible to use forEach() method in this exercise?
**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 = [];
for (let i in arr) {
arr.forEach(k => failureItems.push(k));
}
return failureItems;
}
const failuresList = makeList(result.failure);
console.log(failuresList);
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Challenge: Create Strings using Template Literals
Link to the challenge: