You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//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.
//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
+
letsum=this.scores.reduce((a,b)=>a+b,0);
26
+
return(sum/this.scores.length).toFixed(1);
27
+
}
6
28
29
+
// Add the status method
30
+
status();{
31
+
letavg=this.average();
32
+
if(avg>=90){
33
+
return'Accepted';
34
+
}elseif(avg>=80){
35
+
return'Reserve';
36
+
}elseif(avg>=70){
37
+
return'Probationary';
38
+
}else{
39
+
return'Rejected';
40
+
}
41
+
}
7
42
43
+
// Add a score of 83 to Bubba Bear's record
44
+
bubbaBear.addScore(83);
45
+
console.log(bubbaBear.scores);// Verify the score addition
8
46
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
+
functionboostStatus(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()}.`);
Copy file name to clipboardExpand all lines: html/exercises/index.html
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,13 @@
8
8
<!-- DON'T TOUCH ANYTHING ABOVE THIS LINE -->
9
9
</head>
10
10
<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 --><ahref="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>
0 commit comments