Javascript_Sales Array
Sales information is always vital to a business. This
could be the start of some very expensive sales software that you
create.
Phase 1
In this exercise, you'll start with five arrays that represent
sales regions, and each array contains four values that represent
the quarterly sales for the region. Then, you’ll summarize the data
in the page, which should look like this:
2. In the HTML file, note the link element that refers to the
CSS file, and the script element refers to the JavaScript
file.
3. In the JavaScript file, note that five arrays are declared with
four values in each. Each of these arrays represents one sales
region, and each of the values in an array represents one sales
quarter. For instance, the sales for the third quarter in region 3
were 2710.
4. Write the code for summing the quarterly sales for each the five
regions and displaying them on the page with the document.write()
method. To do that, use an <h2> tag for each header and a
<br> tag for a line break at the end of each line of sales
data.
5. Write the code for getting and displaying the regional sales
data.
6. Write the code for getting and displaying the total sales
data.
Hand in 4 total files, with the changes described above\/
the .html file,
a.js file for each phase, (sales, sales2)
and the .css file
Sales Data Sales by Quarter Q1: $9965 Q2: $7403 Q3: $9478 Q4: $13061 Sales by Region Region 1: $5355 Region 2: $9585 Region 3: $9398 Region 4: $6195 Region 5: $9374 Total Sales $39907 1. Down the zip that has three files.html.js, .css
<> index.html > ... 1 <!DOCTYPE html> SALES_ARRAYS > index.html # sales.css JS sales.js N P 3 4 5 N 6 7 8 9 <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="sales.css"> <title>Sales Data</title> </head> <body> <main> <h1>Sales Data</h1> <script src="sales.js"></script> </main> </body> </html> 10 11 12 13 SM 14 15 16 ол
17 LT ED SALES_ARRAYS <> index.html # sales.css JS sales.js 3 N m n N 000 6 7 h1 { div { # sales.css > Bbody 1 body { font-family: Arial, Helvetica, sans-serif; background-color: I white; 4 margin: auto; 5 width: 500px; border: 3px solid blue; padding: © 2em 1em; 8 } 9 10 color: Oblue; 11 } 12 13 margin-bottom: 1em; } 15 label { 16 display: inline-block; 17 width: 11em; text-align: right; 19 } 20 input { 21 margin-left: 1em; margin-right: 0.5em; 23 } span { 25 color: red; 26 } 14 an 18 22 24 )
DO @ SALES_ARRAYS <> index.html # sales.css JS sales.js JS sales.js > . 1 "use strict"; 2 3 const regioni [1540, 1130, 1580, 1105]; 4 const region2 [2010, 1168, 2305, 4102]; 5 const region3 = [2450, 1847, 2710, 2391]; 6 const region4 [1845, 1491, 1284, 1575]; 7 const regions [2120, 1767, 1599, 3888]; Nm in = =
Phase 2 Now we want to take this to the next level by adding validation to user input. You will be turning in a .js for each phase, so step 1 is to make a copy. 1. Make a copy of your.js file and call it sales2.js 2. Change the arrays to be only 2 regions, but keep the same 4 quarters. 3. Ask the user to enter data for each of those 8 data points using the prompt() command. 4. Validate each of the entries using a loop and make sure that they enter a number between 1000 and 5000. Keep prompting them until they enter a good number. 5. Process the data the same way as before with the same type of output. 6. Use the span in the .css file to make the number totals red in this phase.
Javascript_Sales Array Sales information is always vital to a business. This could be the start of some very expensive
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Javascript_Sales Array Sales information is always vital to a business. This could be the start of some very expensive
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!