Question: Task 4 : You will create an application that asks the user for a list of 4 colors. You will then display the colors sorted

Task 4:
You will create an application that asks the user for a list of 4 colors. You will then display the colors sorted ascending or descending.
In the same Lesson26 workspace, add a new file and name it color.html.
Link your color.html to the index.html using the anchor tag
Link your index.html to color.html using the anchor tag
Add the script tag in color.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 colors
Adds the 4 colors the end user typed into the array named colors
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 colors
Adds the 4 colors the end user typed into the array named colors
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!