Skip to content

Commit cb13725

Browse files
committed
studio class 7
1 parent 017adcd commit cb13725

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

objects-and-math/studio/ObjectsStudio01.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
// Code your selectRandomEntry function here:
2-
2+
function selectRandomEntry(arr) {
3+
let index = Math.floor(Math.random()*arr.length);
4+
return arr[index];
5+
}
36

47
// Code your buildCrewArray function here:
5-
8+
function createCrewArray(id, candidates){
9+
crewSelection = []
10+
for (i=0; i < id.length; i++){
11+
for (c=0; c<candidates.length; c++){
12+
if (candidates[c].astronautID === id[i]){
13+
crewSelection.push(candidates[c]);
14+
}
15+
}
16+
}
17+
return crewSelection
18+
}
619

720
let idNumbers = [291, 414, 503, 599, 796, 890];
21+
let chosenCrew = []
22+
23+
while (chosenCrew.length < 3) {
24+
chosenForLaunch = selectRandomEntry(idNumbers);
25+
if (!chosenCrew.includes(chosenForLaunch)){
26+
chosenCrew.push(chosenForLaunch);
27+
}
28+
}
829

930
// Here are the candidates and the 'animals' array:
1031
let candidateA = {
@@ -53,3 +74,5 @@ let candidateF = {
5374
let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF];
5475

5576
// Code your template literal and console.log statements:
77+
78+
console.log(`${chosenCrew} are going to space!`)

objects-and-math/studio/ObjectsStudio02.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
// Code your orbitCircumference function here:
2-
2+
function orbitCircumference(distance){
3+
let circumfrence = Math.round(2*PI*2000);
4+
return circumfrence
5+
}
36

47
// Code your missionDuration function here:
5-
8+
function missionDuration(time){
9+
orbitRadius = 2000
10+
orbitalSpeed = 28000
11+
time = (circumfrence/orbitalSpeed)
12+
numOfOrbits = ((orbitalSpeed*time)/circumfrence)
13+
}
614

715
// Copy/paste your selectRandomEntry function here:
8-
16+
function selectRandomEntry(arr) {
17+
let index = Math.floor(Math.random()*arr.length);
18+
return arr[index];
19+
}
920

1021
// Code your oxygenExpended function here:
1122

0 commit comments

Comments
 (0)