Answers for "function that return shortest of words in the given array js"

1

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));
Posted by: Guest on April-22-2021

Code answers related to "function that return shortest of words in the given array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language