-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjs-with-html-lec.html
More file actions
166 lines (90 loc) · 2.64 KB
/
js-with-html-lec.html
File metadata and controls
166 lines (90 loc) · 2.64 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
<title>JS W/ HTML</title>
<style>
body{
font-family: 'Open Sans', sans-serif;
}
.container{
width: 80%;
margin: auto;
}
ul {
list-style-type: circle;
}
</style>
</head>
<body>
<div class="container">
<h1>JAVASCRIPT WITH HTML</h1>
<h3>Inline JS</h3>
<ul>
<li>Inline JS Example</li>
<li>Logging to the console</li>
</ul>
<br>
<h3>External JS</h3>
<ul>
<li>Create an external-lec.js file and link to this html file</li>
<li>External JS Example</li>
<li>Using strict - age example (from curriculum)</li>
</ul>
<br>
<h3>User Interaction</h3>
<ul>
<li>Alert</li>
<li>Confirm</li>
<li>Prompt</li>
</ul>
</div>
<script>
"use strict";
/* **************************************
THIS IS AN INLINE EXAMPLE
****************************************/
// Your javascript code goes in this script tag!
//TODO: Console.log "Hello from inline javascript"
// console.log("hello from inline javascript");
// console.log("This is a message!");
</script>
<!--TODO: ADD EXTERNAL JS-->
<!--<script src="js/external-js-lec.js"></script>-->
<script>
// This is for the user interactions
//TODO: Comment out previous scripts
/* *******************************
* ALERTS
* *******************************/
//TODO TOGETHER: Write an alert ---> alert("Message goes here.");
// alert("This is an alert!!!!");
//TODO: Write an alert with an alert message
/* *******************************
Confirm
*******************************/
//TODO TOGETHER: Write a confirm interaction and console.log the result
// var userConfirm = confirm("Would you like to exit?");
//
// console.log(userConfirm);
//
// alert("The user selected: " + userConfirm);
// TODO: Select the OK option. View the result. Select the cancel option. View the result.
/*******************************
Prompts
******************************/
// TODO TOGETHER: Write a prompt interaction. Console.log the result
var userPrompt = prompt("What is your favorite animal?");
console.log(userPrompt);
console.log(typeof userPrompt);
var userNumber = Number(prompt("What is your favorite number?"));
console.log(userNumber);
console.log(typeof userNumber);
// TODO: Write an additional prompt. Console.log the result
</script>
</body>
</html>