-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarWarsScene.js
46 lines (33 loc) · 975 Bytes
/
starWarsScene.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
function spotEachRebel(rebels) {
var spottedRebelCalls = []
if (rebels) {
spottedRebelCalls.push('Look! Rebel scum!')
}
return spottedRebelCalls
}
function seeRebelsEscape(rebels) {
var escapedRebelCalls = []
var i = 0
do {
escapedRebelCalls.push('Oh no! They\'re getting away!')
i++
} while (rebels[i] && rebels[i]['plotArmor'])
return escapedRebelCalls
}
function shootAtNothing() {
var shotsAtNothing = []
for (var i = 1; i < 4; i++) {
shotsAtNothing.push('pew')
}
return shotsAtNothing
}
module.exports.deliverStormTroopersEscapeScene = function (rebels) {
var sceneSequence = []
var spottedRebelCalls = spotEachRebel(rebels)
sceneSequence = sceneSequence.concat(spottedRebelCalls)
var escapedRebelCalls = seeRebelsEscape(rebels)
sceneSequence = sceneSequence.concat(escapedRebelCalls)
var shotsAtNothing = shootAtNothing()
sceneSequence = sceneSequence.concat(shotsAtNothing)
return sceneSequence
}