Skip to content

Commit c1c5898

Browse files
committed
Sure
1 parent 6b592b0 commit c1c5898

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

lecture-testing/math.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function roll1d20() {
2+
return Math.ceil(Math.random()*20);
3+
}
4+
5+
for (let i = 0; i <20; i++) {
6+
console.log(roll1d20());
7+
8+
}

lecture-testing/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
let students = {
2+
names: ["Gerard Darris", "Banana Cat", "Apple Dog", "Mango Zebra", "Kiwi Kiwi"],
3+
scores: [100, 95, 74, 82, 91]
4+
};
5+
6+
for (let i = 0; i < students["names"].length; i++) {
7+
let output = "";
8+
9+
for (items in students) {
10+
output += `${students[items][i]}: `
11+
}
12+
console.log(output.slice(0, -2));
13+
}

objects-and-math/studio/ObjectsStudio01.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
// Code your selectRandomEntry function here:
2+
function selectRandomEntry(arr) {
3+
const randomIndex = Math.floor(Math.random() * arr.length);
4+
return arr[randomIndex];
5+
6+
}
27

38

49
// Code your buildCrewArray function here:
10+
function buildCrewArray(idNumbers, candidates) {
11+
let crew = [];
12+
13+
for (id of idNumbers) {
14+
for (const candidate of candidates) {
15+
if (candidate.astronautID === id) {
16+
crew.push(candidate);
17+
}
18+
}
19+
}
520

21+
return crew;
22+
}
623

724
let idNumbers = [291, 414, 503, 599, 796, 890];
825

26+
27+
928
// Here are the candidates and the 'animals' array:
1029
let candidateA = {
1130
'name':'Gordon Shumway',
@@ -52,4 +71,8 @@ let candidateF = {
5271

5372
let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF];
5473

74+
const crew = buildCrewArray(idNumbers, animals);
75+
5576
// Code your template literal and console.log statements:
77+
78+
console.log(`${candidate} are going to space!`);

0 commit comments

Comments
 (0)