Skip to content

Commit c9d06fd

Browse files
committed
HTML Test 1
1 parent 0eb74d4 commit c9d06fd

File tree

2 files changed

+75
-5
lines changed

2 files changed

+75
-5
lines changed

classes/studio/ClassStudio.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,75 @@
11
//Declare a class called CrewCandidate with a constructor that takes three parameters—name, mass, and scores. Note that scores will be an array of test results.
2+
class CrewCandidate {
3+
constructor(name, mass, scores) {
4+
this.name = name;
5+
this.mass = mass;
6+
this.scores = scores;
7+
}
8+
}
29

10+
let bubbaBear = new CrewCandidate("Bubba Bear", 135, [88, 85, 90]);
11+
let merryMaltese = new CrewCandidate("Merry Maltese", 1.5, [93, 88, 97]);
12+
let gladGator = new CrewCandidate("Glad Gator", 225, [75, 78, 62]);
313

14+
console.log(bubbaBear);
15+
console.log(merryMaltese);
16+
console.log(gladGator);
417

518
//Add methods for adding scores, averaging scores and determining candidate status as described in the studio activity.
19+
// Add the addScore method
20+
addScore(score); {
21+
this.scores.push(score);
22+
}
23+
// Add the average method
24+
average(); {
25+
let sum = this.scores.reduce((a, b) => a + b, 0);
26+
return (sum / this.scores.length).toFixed(1);
27+
}
628

29+
// Add the status method
30+
status(); {
31+
let avg = this.average();
32+
if (avg >= 90) {
33+
return 'Accepted';
34+
} else if (avg >= 80) {
35+
return 'Reserve';
36+
} else if (avg >= 70) {
37+
return 'Probationary';
38+
} else {
39+
return 'Rejected';
40+
}
41+
}
742

43+
// Add a score of 83 to Bubba Bear's record
44+
bubbaBear.addScore(83);
45+
console.log(bubbaBear.scores); // Verify the score addition
846

9-
//Part 4 - Use the methods to boost Glad Gator’s status to Reserve or higher. How many tests will it take to reach Reserve status? How many to reach Accepted? Remember, scores cannot exceed 100%.
47+
// Verify the average score calculation for Merry Maltese
48+
console.log(merryMaltese.average()); // Should print 92.7
49+
50+
// Print the status of each candidate
51+
console.log(`${bubbaBear.name} earned an average test score of ${bubbaBear.average()}% and has a status of ${bubbaBear.status()}.`);
52+
console.log(`${merryMaltese.name} earned an average test score of ${merryMaltese.average()}% and has a status of ${merryMaltese.status()}.`);
53+
console.log(`${gladGator.name} earned an average test score of ${gladGator.average()}% and has a status of ${gladGator.status()}.`);
54+
55+
56+
//Part 4 - Use the methods to boost Glad Gator’s status to Reserve or higher. How many tests will it take to reach Reserve status? How many to reach Accepted? Remember, scores cannot exceed 100%.
57+
// Function to boost scores to reach a specific status
58+
function boostStatus(candidate, targetStatus) {
59+
while (candidate.status() !== targetStatus) {
60+
candidate.addScore(100); // Add a perfect score
61+
if (candidate.average() > 100) {
62+
// Prevent average from exceeding 100%
63+
candidate.scores.pop();
64+
break;
65+
}
66+
}
67+
}
68+
69+
// Boost Glad Gator's status to Reserve
70+
boostStatus(gladGator, 'Reserve');
71+
console.log(`${gladGator.name} earned an average test score of ${gladGator.average()}% and has a status of ${gladGator.status()}.`);
72+
73+
// Boost Glad Gator's status to Accepted
74+
boostStatus(gladGator, 'Accepted');
75+
console.log(`${gladGator.name} earned an average test score of ${gladGator.average()}% and has a status of ${gladGator.status()}.`);

html/exercises/index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
<!-- DON'T TOUCH ANYTHING ABOVE THIS LINE -->
99
</head>
1010
<body>
11-
<!-- h1 goes here -->
12-
<!-- ol goes here -->
13-
<!-- a goes here -->
14-
<!-- p goes here -->
11+
<!-- h1 goes here --> <h1>Why I Love Web Development</h1>
12+
<!-- ol goes here --> <ol>
13+
<li>It allows for creative expression through coding.</li>
14+
<li>The ability to solve real-world problems with technology.</li>
15+
<li>Constant learning and evolving with new technologies.</li>
16+
</ol>
17+
<!-- a goes here --><a href="https://www.webelements.com/" target="_blank">WebElements</a>
18+
<!-- p goes here --> <p>With my web development superpowers, I want to create a dynamic and interactive website that helps people learn new coding skills. This website will feature tutorials, coding challenges, and community forums to foster learning and collaboration among developers of all levels.</p>
1519
</body>
1620
</html>

0 commit comments

Comments
 (0)