-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
74 lines (68 loc) · 1.3 KB
/
app.js
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
let name = "David";
const stateAmt = 50;
//add function usage
let numSum = add(5, 4);
var veggies = ["corn", "spinach", "squash", "okra"];
console.log(sayHello());
console.log(numSum);
function add(num1, num2) {
return num1 + num2
};
function sayHello() {
alert("Hello World!!");
}
for (let i of veggies) {
console.log(i);
}
function checkAge(name, age) {
if (age >= 21) {
console.log("Welcome to the page!" + " " + name)
} else {
console.log("Sorry " + name + ", you aren't old enough to view this page!")
}
}
checkAge('charles', 21);
checkAge("abby", 27);
checkAge("james", 18);
checkAge("john", 17);
let pet = {
name: "Major",
breed: "Pug"
};
console.log(pet.name)
console.log(pet.breed)
let people = [
{
'name': "david",
"age": 34
},
{
"name": "stacey",
"age": 33
},
{
"name": "scotty",
"age": 20
},
{
"name": "adam",
"age": 19
},
{
"name": "kyle",
"age": 35
},
]
for (let i = 0; i < people.length; i++) {
checkAge(people[i].name, people[i].age);
};
// var str = "Hello World"
function getLength(phrase) {
return phrase.length
};
let output = getLength("Hello World");
if (output % 2 === 0) {
console.log("even")
} else {
console.log("odd")
}