forked from devleagueprep/js-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
251 lines (188 loc) · 7.38 KB
/
index.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// Comments are text that will not be executed in your code. Rather comments are for other programmers to read.
// Single line comments start with //
/* Multiple line comments start with*/ /* and end with */
/* All of the exercises below are commented out. Write your Javascript code after each exercise. */
/* Variables and Data Types */
/*Console.log each variable and test your code in the terminal using the Node REPL*/
/*i.e.*/
var pet = "sebastian the pug";
console.log(pet); // <= this should print out sebastian the pug
/*
* #1
* Variables with a "String" value
* Declare variables named firstName, lastName, birthPlace, favFood, favDrink, favSong, favAnimal, favColor, favSport, favDoughnut.
* Assign your own string values to each variable and console.log each variable.
*/
var firstName = 'Vic';
console.log(firstName);
var lastName = 'Lee';
console.log(lastName)
/*
* #2
* Variables with a Number value
*
* Declare variables named favNumber, yourShoeSize, thatOnePrinceSong, floorsAlaMoanaHotel, numOfJapanPrefectures, numOfABCstoresinHi, and cheesecakesFlavAtCheeseCakeFac
*
* Assign your own number values to each variable and console.log each variable.
*/
/*
* #3
* Variables with a Boolean value
*
* Declare variables named likesMcDonalds, eatsDoughnuts and ownsRedShoes.
*
* Assign your own boolean values to each variable and console.log each variable.
*
*
* Now, use comparison and logic operators (>, <, >=, <=, ===, !==) to make the following variables True of False
*
* Console.log each variable.
*
*/
//For example:
//Make me True:
var booya1 = 3 > 2;
console.log(booya1);
//Make me False:
var booya2;
//Make me True:
var booya3;
//Make me False:
var booya4;
//Make me True:
var booya5;
//Make me False:
var booya6;
/*
* #4
* Variables with a Null value
*
* Declare variables named completedPrepClass, traveledToMars and buyVicADrink.
*
* Assign a null value to each variable and console.log each variable.
*/
/*
* #5
* Variables with a undefined value.
*
* Declare a variable named superBowlChamps, nextPres and hawaiiRail.
*
* Do not assign a value to the variable and console.log each variable.
*/
/*
* #6
* Variables with an Array value
*
* Declare a variable named plateLunch and assign it an array containing 5 of your favorite lunch items.
* Declare a variable named `donutBox` and assign it an array containing 5 donuts of your choosing.
* Declare a variable named `westCoast` and assign it an array containing states found on the west coast of the US.
* Declare a variable named `lotteryResult and assign it an array containing 5 random numbers.
* Declare a variable named `hamajang` and assign it an array containing 6 different data types.
* Declare a variable named `dynamicDuos` and assign it an array containing 3 arrays, with each array containing items that match with one another.
*
* Console.log each variable.
*/
//*7
//Accessing values in Arrays
var partyList = ["carrot cake", "gin & tonic", "kalua pork nachos", "double stuff oreos", "cool ranch doritos", "orange chicken"];
// Console.log the entire array.
// Console.log the length of this array.
// Console.log only "carrot cake" from this array.
// Console.log only "cool ranch doritos" from this array
/*
* #8
* Concatenation
* Concatenate the variables `firstName` and `lastName` from exercise 1 and store them into a new variable called `fullName` (don't forget to include a space between the firstName and lastName).
*
* Using the fullName and birthPlace variables, console.log the following:
*
* "Hi my name is fullName and I was born in birthPlace."
*
* i.e "Hi my name is Bruce Wayne and I was born in Gotham."
*/
/*
* #9
* Arithmetic
* Variables with the outcome of an arithmetic operation.
* Declare two variables, `num1` and `num2` and assign each of these variables a number of your choosing.
* Next perform the following arithmetic operations:
* Add the two variables and store it to new variable named sum.
* Subtract the two variables and store it to a new variable named difference.
* Mulitply the two variables and store it to a new variable named product.
* Divide the two variables and store it to a new variable named quotient.
* Find the remainder (modulus) of the two variables and store in to a new variable names leftOver.
*
* Console.log each new variable.
*/
/*
* #10
* Comparisons & Logic
* Variables with the outcome of a comparison operation:
*
* Declare a variable named `isStrictlyEqual` and compare two strings "Tacocat" and "tacocat" using the strict equality (===).
* Declare another variable named `isLooselyEqual` and compare the two strings "Tacocat" and "tacocat" using equality (==).
* Declare a variable named `sameNum` and compare a string "5" and a number 5 using strict equality.
* Declare another variable named `sameNumba` and compare a string "5" and a number 5 using equality.
* Console.log the variables. Do you see the difference between strict equality vs. equality?
*/
/*
* #11
* Logical AND Logical OR
* Use comparison and logic operators (>, <, >=, <=, ===, !==) with the logical && and logical || to make the following variables True of False:
*/
//Use && to make me True
var booya7;
//Use && to make me False
var booya8;
//Use || to make me True
var booya9;
//Use || to make me False
var booya10;
//Console.log each variable
/*
* #12
* Assignments
* Variables with the outcome of an assignment operation (+=, -=, *=, /=, %=):
*
* Declare a variable named `myNum` and assign it with a number of your choosing.
*
* Change the value of the muNum variable by using the assignment operators and console.log myNum after each assignment.
*/
//increment and assign 3 (+=):
//decrement and assign 1 (-=):
//multiple and assign 2 (*=);
//divide and assign 5 (/=);
//modulo and assign 4 (%=);
/*===================================================================*/
/*
* Final Boss
* The following exercises are designed to further challenge you and give you a jump start on the next topic that'll be covered. Let the boss battle begin!
*
* Function - A block of code designed to perform a particular task. It allows you to reuse code.
*
* Declare a function named bakePie which has a single parameter ingredient.
*
* When the function is invoked, it should return a string, "Today's special is ingredient pie." Where ingredient will be the value that you pass into the function.
*
* For example, if the value is `blueberry`, it should return "Today's special is blueberry pie."
*
* Declare a variable pieResult and assign it to the function call.
* Console.log the variable to see the result.*/
/*
* Declare a Function named jump which has a single parameter, height.
*
* This function should return a string, "You jumped height feet high!" Where height will be the value that you pass into the function.
*
* For example, if the value is 9, it should return "You jumped 9 feet high!"
* Declare a variable jumpResult and assign it to the function call.
* Console.log the variable to see the result.
*/
/*
* Declare a Function named makeFood which takes three parameters, ingredient1, ingredient2, recipeName.
*
* This function should return a string ingredient1 and ingredient2 make a recipeName. Where ingredient1, ingredient2 and recipeName will be the values that you pass into the function.
*
* For example, if the values are "Cheese", "Bacon", "pancake" it should return "Cheese and bacon make a pancake."
*
* Declare a variable foodResult and assign it to the function call. Console.log the variable to see the result.
*/