You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises.js
+18-16Lines changed: 18 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,20 @@
1
1
/*
2
2
If statements - Evaluates (or checks) a condition. If the condition is true, any statements in the subsequent code block are executed
3
3
*/
4
+
vartoday=newDate();
4
5
5
6
if(today==="Friday"){
6
-
return"Let's Party!";
7
+
console.log("Let's Party!");
7
8
};
8
9
9
10
/*
10
11
If/else statements = Evaluates (or checks) a condition. If the condition is true, the first code block is executed. If the condition is false, the second code block is executed instead.
11
12
*/
12
13
13
14
if(today==="Friday"){
14
-
return"Let's Party!";
15
+
console.log("Let's Party!");
15
16
}else{
16
-
return"Get back to coding!";
17
+
console.log("Get back to coding!");
17
18
};
18
19
19
20
@@ -77,7 +78,7 @@ if(today === "Friday"){
77
78
* @param Datatype: String `word`
78
79
* @return Datatype: String
79
80
*
80
-
* The function will return the message "Word to Big Bird!", if the string passed into the function is a threeletter word.
81
+
* The function will return the message "Word to Big Bird!", if the string passed into the function is a three-letter word.
81
82
* Console.log your result.
82
83
*/
83
84
@@ -91,7 +92,7 @@ if(today === "Friday"){
91
92
* @param Datatype: String `second`
92
93
* @return Datatype: String
93
94
*
94
-
* The function will return the message "You look mahvelous!", if the strings are equal, otherwise return the message: "I don't know who you are anymore."
95
+
* If the strings are equal, the function will return the message "You look mahvelous!" Otherwise, return the message: "I don't know who you are anymore."
95
96
* Console.log your result.
96
97
*/
97
98
@@ -105,7 +106,7 @@ if(today === "Friday"){
105
106
* @param Datatype: String `second`
106
107
* @return Datatype: String
107
108
*
108
-
* The function will return the message "Opposites do attract", if the strings are not equal, otherwise return the message: "Cause it's like you're my mirror."
109
+
* If the strings are not equal, the function will return the message "Opposites do attract." Otherwise, return the message: "Cause it's like you're my mirror."
109
110
* Console.log your result.
110
111
*/
111
112
@@ -118,7 +119,7 @@ if(today === "Friday"){
118
119
* @param Datatype: Number `money`
119
120
* @return Datatype: Boolean
120
121
*
121
-
* The function will return true if the number passed into the function is greater than 100, otherswise it will return false.
122
+
* The function will return true if the number passed into the function is greater than 100, otherwise it will return false.
122
123
* Console.log your result.
123
124
*/
124
125
@@ -146,7 +147,7 @@ if(today === "Friday"){
146
147
* @param Datatype: Number `num`
147
148
* @return Datatype: Boolean
148
149
*
149
-
* The function will return true if the number passed in is an even value, otherwise it will return false.
150
+
* The function will return true if the number passed in is an even integer, otherwise it will return false.
150
151
* Console.log your result.
151
152
*/
152
153
@@ -160,7 +161,7 @@ if(today === "Friday"){
160
161
* @param Datatype: Number `age`
161
162
* @return Datatype: String
162
163
*
163
-
* The function will return the message: "Welcome to the Legends Lounge." if BOTH values are over 21, otherwise it will return the message: "Chuck E Cheese is across the street."
164
+
* If BOTH values are 21 or over, the function will return the message: "Welcome to the Legends Lounge." Otherwise, it will return the message: "Chuck E Cheese is across the street."
164
165
* Console.log your result.
165
166
*/
166
167
@@ -174,7 +175,7 @@ if(today === "Friday"){
174
175
* @param Datatype: Boolean `thesis`
175
176
* @return Datatype: String
176
177
*
177
-
* The function will return the message: "Congratulations on a job well done." if EITHER the number value is greater than or equal to 120 or boolean value is true, otherwise return the message: "See you in summer school."
178
+
* If EITHER the number value is greater than or equal to 120 or the boolean value is true, then the function will return the message: "Congratulations on a job well done." Otherwise, return the message: "See you in summer school."
178
179
* Console.log your result.
179
180
*/
180
181
@@ -195,17 +196,18 @@ if(today === "Friday"){
195
196
/*
196
197
* #14
197
198
* Function - buyDoughnut
198
-
* Create a function named `buyDoughnut` which takes NO parameter.
199
199
* Declare a variable named `budget` and assign it with a number value that is greater than 20.
200
200
* Declare a variable named `doughnutPrice` and assign it with a number value that is greater than 0 but less than 6.
201
201
* Declare a variable named `doughnutBought` and assign it with a number value of 0.
202
202
*
203
+
* Create a function named `buyDoughnut` which takes NO parameters.
203
204
* When the function is invoked, the budget will be decreased by the doughnutPrice and doughnutBought will increase by 1.
204
205
* Console.log budget and doughnutBought.
205
206
* Invoke your function again.
206
207
* Console.log budget and doughnutBought again.
207
208
*/
208
209
210
+
209
211
/*
210
212
For loops - A for loop checks a condition a specific number of times and allows us to execute a code block and evaluate a condition to determine if our loop should run again.
211
213
@@ -244,14 +246,14 @@ for (var i = 0; i<toyotaModels.length; i++){
244
246
/*
245
247
* #17
246
248
* Function - sumItUp
249
+
* Declare a variable named `numArray` and assign it with an array of 5 random numbers of your choice.
250
+
* Declare a variable named `total` and assign it with a number value of 0.
251
+
*
247
252
* Create a function named sumItUp which takes a parameter: `arr`.
248
253
*
249
254
* @param Datatype: Array `arr`
250
255
* @return Datatype: Number
251
256
*
252
-
* Declare a variable named `numArray` and assign it with an array of 5 random numbers of your choice.
253
-
* Declare a variable named `total` and assign it with a number value of 0.
254
-
*
255
257
* The function will loop through and add up all the values in the array that is passed into the function and return the total.
256
258
* Console.log your result.
257
259
*/
@@ -265,7 +267,7 @@ for (var i = 0; i<toyotaModels.length; i++){
265
267
* @param Datatype: Array `ballers`
266
268
* @return Datatype: Array
267
269
*
268
-
* The function will loop through the players array and will put all the even numbered indexed players in the empty east array and the rest in the empty west array.
270
+
* The function will loop through the players array and will put all the even number indexed players in the `east` array and the rest in the `west` array.
269
271
* Console.log both the east and west arrays.
270
272
*/
271
273
@@ -297,7 +299,7 @@ Final Boss
297
299
* @param Datatype: String `str`
298
300
* @return Datatype: Array
299
301
*
300
-
* The function will loop through the string value and put all the letters into an array, except for the letter "A" and "a". We don't want no stinking "A" or "a" in our array.
302
+
* The function will loop through the string value and put all the letters into an array, except for the letter "A" and "a". We don't want no stinking "A" or "a" in our array. Test your function with the `phrase` below!
301
303
*/
302
304
303
305
varphrase="An apple a day keeps Alice feeling awesome!"
0 commit comments