-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript
More file actions
41 lines (31 loc) · 1.07 KB
/
JavaScript
File metadata and controls
41 lines (31 loc) · 1.07 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
## command + option + J = open the console
5 primitive datatypes:
## numbers
3/9.5/-10
a % b: remainder operator
## strings
"Hello World"/"43"
concatenation
escape character: \" \" "hi\\">> "hi\"
## booleans true/false
## null
## undefined null/undefined (value)
//this is the comments in js; clear()
var userName = prompt(): ask for some input, and it stores in a variable
alert(): be obnoxious, alert something in a pop-up
console.log(): print something to the console
== performs type coercion, while === does not
--------------------------------------------------------------------------------------------------------------------------
100th lecture! BOOM BOOM POW!
// If age is a perfect square
if(age % Math.sqrt(age) === 0) {
console.log("Your age is a perfect square!");
}
While writing a WHILE loop, don't forget to include <script></script> in the html file.
str.indexOf("xxx") === -1: not there
// learn how to use Google:
function kebabToSnake(string) {
// replace - with _, then return as string
var result = string.replace(/-/g, "_")
return result
}