ES6: Create Strings using Template Literals question1235

Tell us what’s happening:
Can someone tell me what I have done wrong?

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 = arr.maps(items => `<li class= "text-warning">${item}</li>`);
// Only change code above this line

return failureItems;
}

const failuresList = makeList(result.failure);

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36.

Challenge: Create Strings using Template Literals

Link to the challenge:

do not add spaces to the requested string

Your need add ‘return’ before strings

good guess! but in this case with arrow function syntax the return is implicit and the return keyword not needed

That’s right, But FCC need that to accept :smiley:

also, the error arr.maps is not a function, is telling you there is something wrong. The method is called map, without the s at the end

also, function parameter of the callback is items but then you use item, so you get a item is not defined error

if you write item => return "string" you get “unexpected token error”

I just try to return “String”
sssss

you have not used implicit return there

// below is valid
x => "String"

// below is valid
x => {return "String";}

// below is not valid
x => return "String";

you suggested to just add return, which would have resulted in the third version

freeCodeCamp accepts totally both valid versions

1 Like

Thank you for the explanation