So, basically I have this:
Array.prototype.toString = function() {
return (\"[\" + this.map(thing => thing = \'\"\' + thing + \'\"\').join(\', \') + \"]\"
You do not return something in the block statement of the arrow function
() => {
// code
return 42; // return is required in block statment
}
() => 42 // return is implicit
Array.prototype.toString = function() {
return ("[" + this.map(thing => { return thing = '"' + thing + '"'}).join(', ') + "]")
};
console.log(['foo', 'bar'].toString())
Shorter, without assignment to thing
Array.prototype.toString = function() {
return ("[" + this.map(thing => '"' + thing + '"').join(', ') + "]")
};
console.log(['foo', 'bar'].toString())