-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUnit4Assignment.html
More file actions
124 lines (95 loc) · 3.98 KB
/
Unit4Assignment.html
File metadata and controls
124 lines (95 loc) · 3.98 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WDV221 Intro Javascript - Unit 4</title>
<style>
span {font-style: italic;}
</style>
<script>
// Define and assign the following global variables
let schoolName = "DMACC";
let firstName = "Colby";
let lastName = "Wemer";
let totalSales = 3435.6;
function formatRosterName(in_first_name, in_last_name) {
return in_last_name + ", " + in_first_name;
}
function printSchoolRoster(inFirstName, inLastName, inSchoolName) {
let rosterName = formatRosterName(inFirstName, inLastName);
let detailLine = rosterName + " " + inSchoolName;
return detailLine;
}
function displayName(fName, lName) {
alert("Name: " + fName + " " + lName);
}
function displaySchool(inValue) {
console.log(inValue);
alert("School: " + inValue);
}
function printName(inFirstName, inLastName){
return inFirstName + " " + inLastName;
}
console.log(printName(firstName, lastName));
function formatCurrency(inNumber){
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(inNumber);
}
</script>
</head>
<body>
<h1>WDV2221 Intro Javascript</h1>
<h2>Unit-4 Assignment - Functions & Parameters </h2>
<h3>Directions:</h3>
<p>Instructions: Define and assign the variables based upon the instructions in the script tags on this page.</p>
<p>Example 1</p>
<ol>
<li>Create a runtime script that will call formatRosterName().</li>
<li>Place the script so that it will display the name in the following heading.</li>
<li>Pass the global variables firstName and lastName into the function.</li>
</ol>
<h4>Student Name: <span><script>document.write(formatRosterName(firstName, lastName));</script></span></h4>
<p>Example 2</p>
<ol>
<li>Create a button called "Display Name".</li>
<li>Assign an onclick event handler to the button that will call displayName().</li>
<li>Pass the global variables firstName and lastName into the function.</li>
<li>Fix the function so that there is proper spacing</li>
</ol>
<button onclick="displayName(firstName, lastName)">Display Full Name</button>
<p>Example 3</p>
<ol>
<li>Create a function called displaySchool( ).
<ul>
<li>the function will accept one input parameter called inValue</li>
<li>the function will display the input value on the console using console.log().</li>
</ul>
</li>
<li>Call this function using a button and the onclick event handler. Pass in the schoolName variable as the parameter to the displaySchool().</li>
</ol>
<button onclick="displaySchool(schoolName)">Display School Name</button>
<p>Example 4</p>
<ol>
<li>Create a function called printName( ).
<ul>
<li>the function will accept two parameters, inFirstName and inLastName</li>
<li>concatenate the names into a single string formatted as "firstName lastName"</li>
<li>display the result string to the console using console.log()</li>
</ul>
</li>
<li>Call this function during runtime. Pass in the firstName and lastName variables as the parameters.</li>
</ol>
<script>document.write(printName(firstName, lastName))</script>
<p>Example 5</p>
<ol>
<li>Create a global variable called totalSales. Assign it a value of 3435.6. It should be numeric data type.</li>
<li>Create a function called formatCurrency().
<ul>
<li>the function will accept one input parameter called inNumber</li>
<li>the function will use the currency formatting discussed in this unit</li>
<li>use a 'return' statement to deliver the formatted number to where the function is called</li>
</ul>
<li>Use a runtime script to display the formatted number instead of the message in the heading shown below. </li>
</ol>
<h3>Your Total Sales: <span><script>document.write(formatCurrency(totalSales))</script></span></h3>
</body>
</html>