-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitch it up.js
More file actions
66 lines (50 loc) · 1.11 KB
/
Switch it up.js
File metadata and controls
66 lines (50 loc) · 1.11 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
//8 Kyu
//Switch it up!
//Fundamentals
// When provided with a number between 0-9, return it in words. Note that the input is guaranteed to be within the range of 0-9.
// Input: 1
// Output: "One".
// If your language supports it, try using a switch statement.
//Solution I
function switchItUp(number){
//using a switch case we can take number and comapre it to the options that our switch will have 0-9
switch(number){
case 0:
return "Zero";
break;
case 1:
return "One";
break;
case 2:
return "Two";
break;
case 3:
return "Three";
break;
case 4:
return "Four";
break;
case 5:
return "Five";
break;
case 6:
return "Six"
break;
case 7:
return "Seven";
break;
case 8:
return "Eight";
break;
case 9:
return "Nine"
break;
}
}
//Parameters
//number>= 0 & number <=9, always an integer, no funny bizz
//Returns
//The word string of the number provided will be the return
//Examples
//console.log(switchItUp(1), 'One')
//console.log(switchItUp(4), 'Four')