how to sort an array in javascript
const points = [40, 100, 1, 5, 25, 10]; points.sort(function(a, b){return a - b}); // for ascending //another way for ascending points.sort((a,b)=>{ if(a>b){ return 1 }else if(a<b){ return -1 }else{ return 0 } }) points.sort(function(a, b){return b - a}); // for descending //another way for descending points.sort((a,b)=>{ if(a>b){ return -1 }else if(a<b){ return 1 }else{ return 0 } })