Javascript is so sucky sometimes.
const array1 = [1, 30, 4, 21, 100000];
array1.sort();
console.log(array1);
// output: Array [1, 100000, 21, 30, 4]
const array2 = [1, 30, 4, 21, 100000];
array2.sort((a,b)=>a-b);
console.log(array2);
// output: Array [1, 4, 21, 30, 100000]
I know that by default it sorts alphabetically, but WHY?! I'M GIVING YOU NUMBERS, SORT NUMERICALLY!
#javascript #JavaScriptShit #makesnosense
JavaScript madness, implementing C in JavaScript in the Browser.
#js #javascript #JavaScriptShit #webdev