function compareFunction(a, b) {
return b - a;
}
const num = [4, 1, 63, 8, 5, 100, 9, 75];
console.log('Before');
console.log(num);
console.log(`\n----------------------------------------------\n`);
const sort4 = num.sort(compareFunction);
console.log(`returns element: ${sort4}`);
console.log('\nAfter');
console.log(num);
This Pen doesn't use any external CSS resources.