Skip to content

Commit 356992b

Browse files
committed
studio done
1 parent 77c31f9 commit 356992b

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

objects-and-math/studio/ObjectsStudio01.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
1+
let idNumbers = [291, 414, 503, 599, 796, 890];
2+
13
// Code your selectRandomEntry function here:
4+
function selectRandomEntry(arr){
5+
candidatesSelected = []
6+
let i;
7+
8+
while (candidatesSelected.length < 3){
9+
i = Math.floor(Math.random()*6)
10+
11+
if (!candidatesSelected.includes(arr[i]))
212

13+
candidatesSelected.push(arr[i])
14+
15+
}
16+
return candidatesSelected
17+
}
318

419
// Code your buildCrewArray function here:
20+
function buildCrewArray (arr1, arr2){
21+
crew = [];
22+
for (i = 0; i < arr2.length ; i++){
23+
if (arr1.includes(arr2[i].astronautID)){
24+
crew.push(arr2[i])
25+
}
26+
}
27+
console.log(`${crew[0].name}, ${crew[1].name}, and ${crew[2].name} are going to space!`)
28+
29+
return crew
30+
31+
}
32+
33+
534

635

7-
let idNumbers = [291, 414, 503, 599, 796, 890];
836

937
// Here are the candidates and the 'animals' array:
1038
let candidateA = {
@@ -53,3 +81,5 @@ let candidateF = {
5381
let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF];
5482

5583
// Code your template literal and console.log statements:
84+
console.log(selectRandomEntry(idNumbers))
85+
console.log(buildCrewArray(candidatesSelected, animals))

objects-and-math/studio/ObjectsStudio02.js

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
11
// Code your orbitCircumference function here:
2+
function findCircumference(radius){
3+
let circumference;
4+
circumference = (2 * Math.PI * radius);
5+
circumference = Math.round(circumference)
6+
return circumference
7+
}
28

3-
9+
410
// Code your missionDuration function here:
11+
function findMissionDuration(orbitsCompleted, orbitRadius, orbitSpeed){
12+
let circumference = findCircumference(orbitRadius)
13+
let missionDuration;
14+
15+
orbitPeriod = (circumference/ orbitSpeed)
16+
missionDuration = (orbitPeriod * orbitsCompleted)
17+
missionDuration = missionDuration.toFixed(2)
18+
return (`The mission will travel ${circumference * orbitsCompleted} km around the planet, and it will take ${missionDuration} hours to complete `)
19+
20+
}
21+
22+
console.log(findMissionDuration(5, 2000, 28000));
523

624

725
// Copy/paste your selectRandomEntry function here:
826

27+
function selectRandomEntry(arr){
28+
candidatesSelected = []
29+
let i;
30+
31+
while (candidatesSelected.length < 1){
32+
i = Math.floor(Math.random()*6)
33+
34+
if (!candidatesSelected.includes(arr[i]))
35+
36+
candidatesSelected.push(arr[i])
937

38+
}
39+
return candidatesSelected
40+
}
1041
// Code your oxygenExpended function here:
1142

43+
function oxygenExpended(astronaut){
44+
let o2;
45+
hours = findMissionDuration(3, 2000, 28000)
46+
o2 = astronaut.o2Used(hours)
47+
return (`${astronaut.name} will perform the spacewalk, which will last ${hours} and require ${o2} kg of oxygen.`)
48+
}
49+
1250

1351
// Candidate data & crew array.
1452
let candidateA = {
@@ -55,4 +93,4 @@ let candidateA = {
5593
};
5694

5795
let crew = [candidateA,candidateC,candidateE];
58-
96+
console.log(oxygenExpended(candidateA));

0 commit comments

Comments
 (0)