DeveloperBreeze

Sorting an Array

// Array of numbers
const numbers = [4, 2, 8, 1, 6];

// Sorting the array in ascending order
const sortedNumbers = numbers.sort((a, b) => a - b);

// Logging the sorted array
console.log('Sorted Array:', sortedNumbers);

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!