function findShort(s){
return Math.min(...s.split(" ").map (s => s.length));
}
var p1 = findShort("bitcoin take over the world maybe who knows perhaps"); //3
var p2 = findShort("turns out random test cases are easier than writing out basic ones") //3
console.log(p1); //3
console.log(p2); //3
找出最短的长度的字符串,这里的...起到什么作用?这好像不是类数组把。。
紫衣仙女
相关分类