-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
327 lines (229 loc) · 6.76 KB
/
test.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/*
..................................................
: ...... :
: .:||||||||:. :
: / \ :
: ( o o ) :
:-------@@@@----------: :----------@@@@---------:
: `--' :
: :
: :
: K I L R O Y S A Y S H I ! :
:................................................:
*/
// yo - says dbristol
// I see you David.
// I know! So maybe you should MOD this discussion! </hint> 😂
// Let's look into modulos next time, I've got a feeling it's going to come in handy. :)
// Given an array/list of numbers, replace numbers divisble by 3 with Fizz, replace numbers divisible by 5 with Buzz, and replace numbers divisible by both with FIZZBUZZ
let basicList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
let movieList = ["Jaws", "Friday the 13th", "KPAX", "Airplane!", "Avatar", "The Fifth Element"];
// this should be solved as [0, 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FIZZBUZZ];
console.log(movieList[0]); // Jaws
function fizzBuzz(numList){
// Insert cool code here
// console.log(numList);
// loop - iterate, or scan through, all of the elements of input array/list.
for(let i = 0; i < numList.length; i++){
// in here.
// console.log(numList[i]);
// here
}
// conditional - if statement, switch statements
if(numList[0] == 0){
}
// return FizzBuzzList;
}
fizzBuzz(basicList);
// Recursion is fun!
function fizzBuzzRec(numList){ // a recursive version
// fizzBuzzRec( info, more info);
}
// Hello world testing area
//Jeff - Test If/Else Loop
// for (let i= 0; i<16 ; i++ ){
// if (condition)
// {
// i/3= //A Whole Number
// //Then replace number with "Fizz"
// if (condition)
// i/5= //A Whole Number
// //Then replace number with "FIZZBUZZ"
// } else
// {
// // Return i
// }
// }
// Variables, conditionals (if, else), Loops! (for, while)
// Next dictionaries, arrays/lists, functions
// After this point, define a variable to hold your name
// True or false? Boolean
let quickBool;
// let quickBool = true;
quickBool = true;
const movementSpeed = 5; // const means constant. It means that this never changes.
// String
let dania = "dania";
// Integers
// let a = 2;
// let b = 3;
// let c = a + b;
// let Cool = "Zach";
// console.log (Cool);
// if( Cool == "Zach"){
// console.log("Zach is the best!");
// } else {
// console.log(Cool + " is the best! Zach is not though.");
// }
// while(Cool == "Zach")
// {
// console.log("Help, I'm stuck in a loop, and everything is bad.");
// Cool = "Joseph";
// }
// for(let i = 0; i < 100; i++)
// {
// console.log(i);
// }
// Make some variables
// Age
// DOB
// FaveVehicle
// likesDogs
let age = 27;
let dob = "19/10/1994";
let FaveVehicle = "RollsRoyce";
let likedogs = false;
let dateThing = Date.now();
// dateThing.getFullYear()
let daniaAge = 104;
let daniaDOB = "01/01/1900";
let daniaFavVehicle = "rollerblabes";
let danialikesDogs = true;
// console.log(daniaAge);
daniaAge = 122;
// console.log(daniaAge);
// c += 10;
// console.log(c);
// c++;
// console.log(c);
// while(c < 1000)
// {
// c += 10;
// console.log(c);
// }
let wordList = ["Hello", "World", 42, "42", "Pizza"];
// console.log(wordList[0]); // What do we get?
// console.log(wordList[4]); // and here?
// console.log(wordList[2]);
// console.log(wordList[3]); // What's different about how these are output?
let map = [
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
]
// console.log(map);
// console.log(map[0]);
// console.log(map[0][5]);
// console.log(map[0][5]);
// console.log(map[0][5]);
let HoldingArray = [
// [],
];
for(let y = 0; y < map.length; y++){
HoldingArray.push([]);
for(let x = 0; x < map[0].length; x++){
// console.log(map[y][x]);
HoldingArray[y].push(map[y][x]);
}
// console.log(map[y]);
}
HoldingArray[3][5] = 25;
// console.log("Holding:", HoldingArray);
// console.log("Map:", map);
// var and let can be used to declare variables.
// let testA = 5;
// let testB = testA;
// testB = testB + 10;
// console.log("test A: " + testA);
// console.log("test B: " + testB);
let test2 = 5
// let x = [0,1,2,3];
// let y = x;
// console.log("before change " + x[0]);
// console.log("before change " + y[0]);
// y[0] = 1000;
// console.log("after " +x[0]);
// console.log("after " + y[0]);
// y.push(20)
// console.log("test x:", x);
// console.log("test y:", y);
// console.log(y[1]);
// console.log(y[0]);
let y = 0
for( null; y<101; null){
// console.log(y);
y++;
}
for (const word in wordList) {
// console.log(wordList[word]);
}
for (const iterator of wordList) {
// console.log(iterator);
}
wordList.forEach(word => {
// console.log(word);
});
let faveFoods = [
"Bacon",
"TurkeyLeg",
"Bacon",
"Bacon",
"Cookies",
"Butterchicken",
"Lasagna"
]
// console.log(faveFoods[4]);
let foodDictionary = {
Zach : "Bacon",
Carlos : "Lambchop",
Corey : "Cookies",
Div : "Muttonchop",
Jman : "Lasagna"
}
// console.log ('Jeff Likes ' + foodDictionary.Jman + ' and ' + (foodDictionary.Corey));
// console.log(`Corey likes ${foodDictionary.Jman} and ${foodDictionary.Corey}`);
// console.log (foodDictionary.Carlos)
// console.log(foodDictionary.Carlos);
// array.forEach(element => {foodDi
// });
// (let index = foodDictionary; index < array.length; index++) {
// const element = array[index];
// console.log(index)
// }
//hz
for (const [key, value] of Object.entries(foodDictionary)) {
// console.log(key, value);
}
//Corey
for(const food in foodDictionary){
// console.log(`We all love ${foodDictionary[food]}`);
}
//Will this work... hmmm :)?
daniaFavVehicle.forEach(item => {
console.log(item);
})
// wordList.forEach(word => {
// // console.log(word);
// });
/*
*/