📜  返回给定数组js中最短单词的函数 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:53.899000             🧑  作者: Mango

代码示例1
words = ["one", "two", "three"];

function getShortestWord(wordsArray) {
    return wordsArray.sort((a, b) => a.length - b.length)[0];
}

console.log(getShortestWord(words));