Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort array by string length javascript

function sortByLength(arr) {
   return arr.sort((x,y) => x.length - y.length);
}
 
PREVIOUS NEXT
Tagged: #sort #array #string #length #javascript
ADD COMMENT
Topic
Name
5+2 =