DeveloperBreeze

Sorting an Array in JavaScript

javascript
// Original array and sorting
let arr = [5, 2, 8, 1, 4];
console.log('Original Array:', arr);

// Sorting the array using the sort method
arr.sort();
console.log('Sorted Array:', arr);

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!