-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day 20
57 lines (45 loc) · 1.46 KB
/
Day 20
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
DAY 20
Instructions
(This challenge is worth 10 points)
Your task is to write a function that will take in speed (number), missionData (object) and checks (object) as parameters. The goal is to make sure that the speed is within the limits and that the amount of entries per type matches with the checks. If one of the values is a mismatch, return false, if everything is fine, return true.
Speed will be compared against maxSpeed and minSpeed inclusively and the length of each array inside missionData will be compared to the values inside the dataEntries object values.
Examples
Input:
const speed = 40
const missionData = {
astro:["...","..."],
bio:["..."],
physics:["..."]
}
const checks = {
maxSpeed:50,
minSpeed:20,
dataEntries:{
astro:3,
bio:1,
physics:1
}
}
Output:
false // Not the same amount of entries
SOLUTION
function confirmReentryPlans(speed, missionData, checks){
if (speed > checks.minSpeed && speed < checks.maxSpeed){
if (checks.dataEntries.astro === missionData.astro.length){
if (checks.dataEntries.bio === missionData.bio.length){
if (checks.dataEntries.physics === missionData.physics.length) {
return true
} else {
return false
}
} else {
return false
}
}
else {
return false
}
} else {
return false
}
}