JS Cara mengurutkan array berdasarkan panjang string
(() => {
let arr = ["HTML", "Go", "Ruby", "Python", "JavaScript", "CSS"];
function sortByLength(arr) {
return arr.sort((a, b) => a.length - b.length);
}
console.log(sortByLength(arr)); // => [ 'Go', 'CSS', 'HTML', 'Ruby', 'Python', 'JavaScript' ]
})();
Condemned Corncrake