function findShort(s){ return Math.min(...s.split(" ").map (s => s.length)); }var p1 = findShort("bitcoin take over the world maybe who knows perhaps"); //3var p2 = findShort("turns out random test cases are easier than writing out basic ones") //3console.log(p1); //3console.log(p2); //3找出最短的长度的字符串,这里的...起到什么作用?这好像不是类数组把。。
1 回答
紫衣仙女
TA贡献1839条经验 获得超15个赞
function findShort(s) {
let arr = s.split(" ").map(s => s.length);
return Math.min(...arr);
}
添加回答
举报
0/150
提交
取消