-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathskillTest-productObjects.html
More file actions
80 lines (55 loc) · 2.43 KB
/
skillTest-productObjects.html
File metadata and controls
80 lines (55 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<head>
<title>WDV221 Intro Javascript</title>
<script type="text/javascript" src="productArrays.js"></script>
<script>
let productList = [];
let currencyFormat = Intl.NumberFormat('en-us',{style:'currency',currency:'USD'});
for (let index = 0; index < productNames.length; index++) {
productList[index] = {prod_name : productNames[index],
prod_number: productNumbers[index],
prod_manufacture_price: productManPrices[index],
prod_suggestedRetailPrice: function(){console.log(currencyFormat.format(this.prod_manufacture_price * 1.67));
return currencyFormat.format(this.prod_manufacture_price * 1.67)}}
}
/*
Product objects have the following properties and methods
prod_name
prod_number
prod_manufacture_price
prod_suggestedRetailPrice( )
this function will create the suggest retail price of the object
to calculate take manufacture_price times 1.67
*/
</script>
</head>
<body>
<h1>WDV221 Intro Javascript</h1>
<h2>Skill Test - Create and Display Javascript Objects</h2>
<h3>Product Inventory List</h3>
<div>
<p>EXAMPLE OUTPUT</p>
<p>Number of Products in Product List: 1</p>
<p>
Product: Standard Keyboard</br>
Product Number: std-key<br>
Product Wholesale Price: $11.90</br>
Product Suggested Retail Price: $19.87</br>
</p>
<p>PROJECT OUTPUT</p>
<p>Number of Products in Product List: <script>document.write(productList.length)</script></p>
<script>
for (let index = 0; index < productList.length; index++) {
document.write("Product: " + productList[index].prod_name + "</br>Product Number: " + productList[index].prod_number + "</br>Product Wholesale Price: " +currencyFormat.format(productList[index].prod_manufacture_price) + "</br>Product Suggested Retail Price: " + productList[index].prod_suggestedRetailPrice() +"</br></br>")
}
</script>
</div>
<h3>Instructions</h3>
<ol>
<li>Attach the external script file as the source for your data</li>
<li>Using the data provided in the external script file create an array of objects called productList using the object format in the script</li>
<li>Use a loop to display the contents of the productList on the page beginning after the Example Output</li>
<li>All prices should be displayed as USD formatted currency</li>
</ol>
</body>
</html>