-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexercise1.js
More file actions
38 lines (29 loc) · 1.03 KB
/
exercise1.js
File metadata and controls
38 lines (29 loc) · 1.03 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
/* EXERCISE 1
/
/ Directions:
/ Write a function that returns an array of 6 random integers between 0 and 60. It's OK if a number repeats.
/
/ When I call the function randomNumbers(), something like this should be returned: [2,3,16,25,40,60] or [1,10,10,11,29,30]
/
/ Input (arguments) : None
/ Output (return) : Array of 6 random integers between 0 and 60
/
/ Tools and functions you'll probably need to use:
/ 1) While-Loop or For-Loop
/ 2) Math.random(), Math.ceil(n) and/or Math.floor(n)
/ 3) Array.prototype.push(item(s)). You've seen this before as just arrayName.push():
/ var imAnArray = [];
/ imAnArray.push(1,2,3);
/
/ In your console:
/ > imAnArray
/ < [1,2,3]
*/
function randomNumbers() {
var arrayOfRandomNumbers = [];
/*
/ CODE HERE
*/
return arrayOfRandomNumbers;
}
window.randomNumbers = randomNumbers;