forked from scriptEd-HSFI/Jan-20-2016-DataStructures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcercise.js
More file actions
51 lines (37 loc) · 1.14 KB
/
excercise.js
File metadata and controls
51 lines (37 loc) · 1.14 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
//Test input:
//pushMeToTheLimit(5);
function pushMeToTheLimit(arrayMax) {
var array = [];
//write code here that pushes sequential numbers to an empty array until the length of the array hits the max
//hint: use a for loop! i.e. for(var i = 0; ...)
//this check will tell you if you've done it right!
if (array.length == arrayMax)
alert("yay");
else
alert("merp");
return array;
}
//Test input:
//findMe(["hi","bye", "ok", "w/e"], "w/e")
function findMe(array, searchWord) {
var indexOfWord;
//write code here that finds the index of the searchWord and sets it to variable indexOfWord
//this check will tell you if you've done it right!
if (array[indexOfWord] == searchWord)
alert("found u");
else
alert(":( nope");
return indexOfWord;
}
//Test input:
//dontStopPopping([1, 2, 3, 4, 5, 6])
function dontStopPopping(array) {
//write code here that removes each element from the array using array.pop
//hint: another for loop!
//this check will tell you if you've done it right!
if (array.length === 0)
alert("Yup you got it");
else
alert("Nah try again :( ");
return array;
}