What am I doing wrong in my little code snippet that I get undefined
instead of number
outcome?
function multiply(multiplier: number, ...args: [number, number, number]) {
return args.map(
element => { multiplier * element; }
);
}
console.log(multiply(2, 5,6,7));
output: [ undefined, undefined, undefined ]
感谢mplungjan的评论,我意识到我应该修改我的map
功能的内容如下:
element => { return multiplier * element; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.