forked from devleague/prep-js-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
178 lines (151 loc) · 4.55 KB
/
functions.js
File metadata and controls
178 lines (151 loc) · 4.55 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* Below are some specifications for Functions to be built.
*
* #1
* Declare Two Variables
* - `a` random Number value
* - `b` random Number value
*
* We will be using both of these variables to pass as `parameters` to the
* following functions that we will write. Pay close attention to the other
* variable names you will create as they will become input to _other_
* functions.
*/
/**
* #2
* Function - add
*
* This function returns the result of adding `a` and `b` together.
* Store this value in a variable named `sum`.
*/
/**
* #3
* Function - subtract
*
* This function returns the result of subtracting `b` from `a`.
* Store this value in a variable named `difference`
*/
/**
* #4
* Function - multiply
*
* This function returns the result of multiplying `b` by `a`.
* Store this value in a variable named `product`
*/
/**
* #5
* Function - checkDifference
*
* This function accesses the value stored in the `difference`
* variable and uses this number to return the string
* "My football team lost X times this week", where `X` is the
* value stored in `difference`.
*/
/**
* #6
* Function - checkSum
*
* This function checks the value stored at `sum` and
* uses that number to print to the screen the phrase
* "I CAN ADDZ X NUMBERS" where `X` is the value
* stored in the variable `sum`.
*/
/**
* #7
* Function - checkProduct
*
* This function checks the value stored at `product` and
* multiplies it by the number stored at `difference` and
* then prints the result to the console.
*/
/**
* #8
* Function - addThenSubtract
*
* This function takes three `Number` arguments named by you,
* then adds the first two arguments together.
* Then with the sum of that operation, subtract
* the value at the third argument. _This function should
* make use of your previous functions_.
*
* **example:**
* addThenSubtract(4, 5, 7); //-> returns 2 because 4 + 5 - 7 = 2
*/
/**
* #9
* Function - addThenMultiply
*
* This function takes three `Number` arguments named by you,
* then adds the first two arguments together.
* Then with the sum of that operation multiply it by the third argument.
* _This function also should make use of your previous functions_.
*
* Store the return of this function to a variable named `howMany`
*/
/**
* #10
* Function - createFullName
*
* @param Datatype: String firstName
* @param Datatype: String lastName
* @return Datatype: String
*
* This function takes two String arguments `firstName` and `lastName`.
* This function `returns` back a string which represents someone's full name.
*
* Call this function and pass your first and last name into it.
* Store the return value to a variable named `myFullName`
*/
/**
* #11
* Function - verifyDrinkingAge
*
* @param Datatype: Number age
* @return Datatype: Boolean
*
* This function takes one Number argument `age`.
* This function returns the `Boolean` value `true` or `false` if `age` is
* lower than the legal drinking age in the state of Hawaii.
*
* **Call this function and pass in a number value.
* Store the return value to a variable named** `canDrinkBeer`
*/
/**
* #12
* Function - throwParty
*
* This function checks the value stored at the `canDrinkBeer` variable and
* if the value is `false` it should print to a message to the screen,
* "The Party will have tons of Cake!" otherwise this message
* should be "This Party will have an open bar".
*/
/**
* #13
* Function - eatFood
*
* This function takes 3 arguments
* `firstName`, `lastName`, `food` and prints out a message to your screen.
* Internally this function will make use of the `createFullName`
* function you created earlier.
*
* **example input:**
* if someone called your program like this `eatFood( "John", "Papa", "Pizza" )`
* **example output:**
* "John Papa loves to eat Pizza"
*
* **example input:**
* if someone called your program like this `eatFood( "Peter", "Bojangles", "California Burritos" )`
* **example output:**
* "Peter Bojanglesloves loves to eat California Burritos"
*/
/**
* #14
* Function - repeater
*
* This function will return a string to that repeats one of the phrases
* below `X` amount of times, where `X` is the value stored at `howMany`.
* Inside of this function it will check if
* the value of `canDrinkBeer`, if the value is true
* the message will be `"Bacon Pancakes, makin' Bacon Pancakes..."`
* othewise the message will be `"Let it go.... LET IT GOOOOOOoOoOoOo..."`
*/