JavaScript Code

How to sort array of numbers in ascending order?

Problem Statement

given an array of numbers, write a JavaScript program to sort the array in ascending order


to sort an array of numbers in ascending order, use array sort() method. sort() method sorts the elements in ascending order, by default


numbers is the given array of numbers. we use sort() to sort numbers in ascending order

let numbers = [5, 1, 7, 3, 2, 0];

copyright @2022