forked from benrbryant/JavaScript_Functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.js
More file actions
36 lines (31 loc) · 787 Bytes
/
notes.js
File metadata and controls
36 lines (31 loc) · 787 Bytes
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
//ex 1
function printOdds(count) {
for (let i = 0; i < count; i++) {
//Check if I is an odd number
if (i % 2 != 0) {
console.log(i);
}
}
}
//ex 2
printOdds(47);
printOdds(6);
function checkAge(userName, age) {
//If the username is a falsey value
//undefined and ""
if (!userName) {
//End the function early
return;
}
const aboveSixteen = "Congrats ${userName}! You're not a child :) "
const belowSixteen = "Sorry ${userName} . . . you. . . are . . . a jitt still you got some growing to do";
if (age < 16 || !age) {
console.log(belowSixteen);
} else {
console.log(aboveSixteen);
}
}
checkAge("Seba Fox", 21);
checkAge("Larry Rotter", 15);
checkAge("Shadowheart", 26);
//ex3