forked from benrbryant/JavaScript_Functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
69 lines (65 loc) · 2 KB
/
app.js
File metadata and controls
69 lines (65 loc) · 2 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
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
function printOdds(count){
if (count < 0){
console.log("Invalid")
}
for(let i = 1; i <= count; i++){
if(i % 2 !== 0){
console.log(i);
}
}
}
printOdds(15);
// Exercise 2 Section
console.log("EXERCISE 2:\n==========\n");
function checkAge(userName, age){
let aboveSixteen = `Congrats ${userName}, you can drive!`;
let belowSixteen = `Sorry ${userName}, but you need to wait until you're 16.`;
if (userName === undefined || age === undefined){
console.log("Invalid input");
return;
}
if (age < 16){
return belowSixteen;
}
else{
return aboveSixteen;
}
}
console.log(checkAge("Daniel", 38));
//Exercise 3 Section
console.log("EXERCISE 3: \n==========\n");
function checkAxis(x,y){
if (x === 0 && y === 0){
console.log ("Dead Center");
}else if (x === 0){
console.log(`The coordinates ${x} and ${y} lie on the y-axis.`);
}else if (y === 0){
console.log(`The coordinates ${x} and ${y} lie on the x-axis.`);
}else if (x > 0 && y > 0){
console.log(`The coordinates ${x} and ${y} lie in Qaudrant 1.`);
}else if (x < 0 && y > 0){
console.log(`The coordinates ${x} and ${y} lie in Quadrant 2.`);
}else if (x < 0 && y < 0) {
console.log(`The coordinates ${x} and ${y} lie in Quadrant 3.`);
}else {
console. log(`The coordinates ${x} and ${y} lie in Quadrant 4.`)
}
}
checkAxis(-10, 5);
//Exercise 4 Section
console.log("Exercise 4: \n==========\n");
function triangle(x,y,z){
if(x + y <= z || x + z <= y || y + z <= x){
console.log("This is an invalid triangle.");
}else if(x===y || x===z || y===z){
console.log("This is an isosceles triangle.");
}else if(x === y && x === z){
console.log("This is an equilateral triangle.");
}else{
console.log("This is a scalene triangle");
}
}
triangle();