Question: Task 5 : You will create an application that asks the user for a list of 4 numbers. You will then display the numbers sorted
Task :
You will create an application that asks the user for a list of numbers. You will then display the numbers sorted ascending or descending.
In the same Lesson workspace, add a new file and name it numbers.html
Link your numbers.html to the index.html and color.html using the anchor tag
Link your index.html and color.html to numbers.html using the anchor tag
Add the script tag in numbers.html in the head or body section of the web page
Alternatively, you may use an external JavaScript file. If you do this, you will need to have the following tags in the body element:
Within the body element, type the following code:
Write a JavaScript function named sortAscending within the script tags that does the following:
Creates an array named numbers
Adds the numbers the end user typed into the array named numbers
Sorts the elements in ascending order and displays it back to the end user
This is an example of what your screen should look like after sorting ascending:
Write a JavaScript function named sortDescending within the script tags that does the following:
Creates an array named numbers
Adds the numbers the end user typed into the array named numbers
Sorts the elements in descending order and displays it back to the end user
This is an example of what your screen should look like after sorting descending:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
