Learn, grow and help others with BBBootstrap
Contribute us with some awesome cool snippets using HTML,CSS,JAVASCRIPT and BOOTSTRAP
Sorting string in Javascript ES6. By default javascript, the sort method organizes elements alphabetically(i.e A-Z).
const items = ['arms','red','green','orange','yellow']; //sort items const sortitems = items.sort(); console.log(sortitems); // ['arms', 'green', 'orange', 'red', 'yellow'] //reverse the items const reverseitems = sortitems.reverse(); console.log(reverseitems); // ['yellow', 'red', 'orange', 'green', 'arms']