Exercise: Sorting and displaying the array

Modify the code in the following ways:

  • When the second button is pushed, the array is sorted.
  • When the third button is pushed, the array is displayed as a list.

Note:

Hints:

  • Use an event listener for each button.

Solution to the exercise

Here is a possible solution.

Note:

Hints:

  • undefined
1
2
window.onload = startFunction;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX