Tell us what’s happening:
Buenas tardes, busque ayuda en el foro pero no encontré una solución a mi duda. Porque la consola devuelve 3 “F” ? Gracias!
Your code so far
function getAverage(scores) {
let sum = 0;
for (const score of scores) {
sum += score;
}
return sum / scores.length;
}
// User Editable Region
function getGrade(score) {
if (score === 100){
return "A++";
} else if (score <= 90 && score >= 99){
return "A";
} else if (score <= 80 && score >= 89){
return "B";
} else if (score <= 70 && score >= 79){
return "C";
} else if (score <=60 && score >= 69){
return "D";
} else {
return "F"
}
}
console.log(getGrade(96));
console.log(getGrade(82));
console.log(getGrade(56));
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Challenge Information:
Review JavaScript Fundamentals by Building a Gradebook App - Step 2
ILM
June 27, 2024, 6:16pm
2
can a number be both less than 90 and more than 99 at the same time?
Okey entiendo… deje mi código así, sigue sin pasar :
function getGrade(score) {
if (score === 100){
return "A++";
} else if (score <= 90){
return "A";
} else if (score <= 80 ){
return "B";
} else if (score <= 70 ){
return "C";
} else if (score <=60 ){
return "D";
} else {
return "F"
}
}
ILM
June 27, 2024, 6:24pm
4
If I add this code
for (let i = 100; i > 0; i--) {
console.log(i, getGrade(i))
}
The grades are like this:
100 A++
99 F
98 F
97 F
96 F
95 F
94 F
93 F
92 F
91 F
90 A
89 A
88 A
87 A
86 A
85 A
84 A
83 A
82 A
81 A
80 A
79 A
78 A
77 A
76 A
75 A
74 A
73 A
72 A
71 A
70 A
69 A
68 A
67 A
66 A
65 A
64 A
63 A
62 A
61 A
60 A
59 A
58 A
57 A
56 A
55 A
54 A
53 A
52 A
51 A
50 A
49 A
48 A
47 A
46 A
45 A
44 A
43 A
42 A
41 A
40 A
39 A
38 A
37 A
36 A
35 A
34 A
33 A
32 A
31 A
30 A
29 A
28 A
27 A
26 A
25 A
24 A
23 A
22 A
21 A
20 A
19 A
18 A
17 A
16 A
15 A
14 A
13 A
12 A
11 A
10 A
9 A
8 A
7 A
6 A
5 A
4 A
3 A
2 A
1 A
Discúlpame pero no entiendo, tengo que agregar ese bucle for a mi codigo?
ILM
June 27, 2024, 6:30pm
6
The loop is to test your function with all possible values.
From the loop you can see that for a score
of 99, your function returns F:
ILM:
99 F
Ahora entendí! Estaba usando mal los signos, muchas gracias por tu explicación!
system
Closed
December 27, 2024, 6:34am
8
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.