So, this code works:
console.clear();
const howMany = (...args) => { return "You have passed " + args.length + " arguments.";
}
console.log(howMany(0, 1, 2)); // You have passed 3 arguments.
console.log(howMany("string", null, [1, 2, 3], { })); // You have passed 4 arguments.
This code doesn’t:
console.clear();
const howMany = (...args) => { "You have passed " + args.length + " arguments.";}
console.log(howMany(0, 1, 2)); // undefined
console.log(howMany("string", null, [1, 2, 3], { })); // undefined
I would have expected that the second example is still a one-line arrow function, and the “return” keyword could be omitted. It can’t, so, should I conclude that because of the use of Javascript string literals it is no longer considered to be a one-line function?