function addTogether(args) {
console.log(args)
return args.some(n => typeof n !== "number")
? undefined
: args.length > 1
? args.reduce((acc, n) => (acc += n), 0)
: n => (typeof n === "number" ? n + args[0] : undefined);
}
Then call it like addTogether([1, 2])
[] Is a array, everything in it, seperated with a comma, is an item in the array. You can only have the same datatype in the array.
In the (), where the function is defined, is where you should define what data you want to get, when the function is called.
If you want to test it quick, copy and paste it into the developer console in your browser, and call the function after
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…