Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

function that return shortest of words in the given array js

words = ["one", "two", "three"];

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

console.log(getShortestWord(words));
Source by codereview.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #function #return #shortest #words #array #js
ADD COMMENT
Topic
Name
1+5 =