js sort array of strings by length code example
Example: sort array by string length javascript
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}
function sortByLength(arr) {
return arr.sort((x,y) => x.length - y.length);
}