Skip to content

Commit 9b98a0d

Browse files
committed
studio
1 parent b6081ac commit 9b98a0d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

objects-and-math/studio/ObjectsStudio01.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
11
// Code your selectRandomEntry function here:
22

3+
function selectRandomEntry(arr) {
4+
let index = Math.floor(Math.random()*arr.length);
5+
return arr[index];
6+
7+
}
38

49
// Code your buildCrewArray function here:
510

611

12+
let callCount = 0;
13+
let newArr = [];
14+
let crewArray = [];
15+
function buildCrewArray(idNumbers, animals) {
16+
while (idNumbers.length !== 0 && callCount < 3) {
17+
let id = selectRandomEntry(idNumbers);
18+
if (!newArr.includes(id)) {
19+
newArr.push(id);
20+
callCount++;
21+
}
22+
}
23+
console.log(newArr)
24+
25+
for (let i=0; i < animals.length; i++){
26+
let candidateObj = animals[i];
27+
for (let j =0 ; j < newArr.length; j++) {
28+
if (candidateObj.astronautID === newArr[j]){
29+
crewArray.push(candidateObj.name);
30+
}
31+
}
32+
}
33+
}
34+
35+
736
let idNumbers = [291, 414, 503, 599, 796, 890];
837

938
// Here are the candidates and the 'animals' array:
@@ -53,3 +82,6 @@ let candidateF = {
5382
let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF];
5483

5584
// Code your template literal and console.log statements:
85+
buildCrewArray(idNumbers, animals);
86+
87+
console.log(`'${crewArray[0]}, ${crewArray[1]}, and ${crewArray[2]} are going to space!`)

objects-and-math/studio/ObjectsStudio02.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Code your orbitCircumference function here:
2+
function orbitCircumference(arr) {
23

4+
let cirOrbit = 2* Math.PI *
5+
}
36

47
// Code your missionDuration function here:
58

0 commit comments

Comments
 (0)