forked from constructorlabs/debugging-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (32 loc) · 766 Bytes
/
index.js
File metadata and controls
41 lines (32 loc) · 766 Bytes
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
function getRandomNumber(maxNumber){
const randomNumber = Math.floor(Math.random() * Math.floor(maxNumber));
return randomNumber;
}
function getCompanyName(index){
const companies = [ 'Google', 'Facebook', 'Amazon', 'Apple', 'Microsoft'];
return companies[index];
}
function getCompany(index){
if(!index){
index = getRandomNumber(4);
}
const company = getCompanyName(index);
return company;
}
function letsGetDebugging( list ){
let company;
for(let i = 0; i < 10; i++){
if(i % 3 === 0){
company = getRandomNumber(i);
} else if(i < 5){
company = getCompany(i);
} else {
company = getCompany();
}
list.push( company );
}
return list;
}
debugger;
const output = letsGetDebugging([]);
debugger;