Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

比如 var arr=["flight", "flow", "flower"];

最短 'flow'

我印象中。。。。
arr.reduce((c,p)=>{return c.length<p.length?c.length:p.length})

我这是错误的写法 忘记如何写了 求大佬更正


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

Array.prototype.reduce 实现

arr.reduce((c, p) => c.length < p.length ? c : p);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...