forked from gocodeup/intro-to-testing-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.js
72 lines (61 loc) · 1.41 KB
/
code.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
// helloWorld function
function helloWorld() {
return "Hello, World!";
}
// function sayHello(input){
// if(input === "Alex"){
// return "Hello, Alex!";
// } else if(input === "Pat"){
// return "Hello, Pat!";
// } else return "Hello, Jane!";
//
// }
//------Refactoring....
// function sayHello(input){
// if(input === undefined || input === true || input === false){
// return "Hello, World!";
// } else {
// return "Hello, " + input + "!";
// }
//
// }
//------Refactoring some more....
function sayHello(input){
if(typeof input === "string"){
return "Hello, " + input + "!";
} else if(typeof input === "number"){
return "I cannot say hello to a number...";
} else if(typeof input === "object") {
return "I cannot say hello to an object...";
} else {
return "Hello, World!";
}
}
function isFive(input){
return (parseInt(input)) === 5;
}
function isEven(input){
return input % 2 === 0;
}
// function isVowel(input){
// return (input === "a" || input === "A");
// }
function isVowel(input) {
switch (input) {
case "a":
case "A":
case "e":
case "E":
case "i":
case "I":
case "o":
case "O":
case "u":
case "U":
return true;
}
return false;
}
function add (input1, input2){
return input1 + input2;
}