+ 2
Loops in ECMAScript 6: Score 70+ !
Students need to score at least 70 points to pass an exam. The given program declares an array with results. Write a program to count and output to the console the number of students who pass the exam. *Use a forâŠof loop to iterate through the array. https://code.sololearn.com/cqFTmH05o4Ng/?ref=app https://code.sololearn.com/cZAe4Evoq4Sp/?ref=app Please help.
8 Respostas
+ 4
You can declare another variable to count the students who have higher marks than 70 and print it outside loop.
+ 3
count is a random name of a variable rather than a keyword. For that, you can use any name you want.
This is the common way to solve a challenge something like that
var Tahiti = 0
for()
if()
Tahiti++
console.log(Tahiti)
+ 2
Tahitiđ·Castillo
2nd code is little bit right but you are increasing scores not counting number of students.
var count = 0;
for (let p of scores) {
if (p>=70){
count++;
}
}
console.log (count);
+ 1
Ok. Thank you Simba . I will try that.
+ 1
AÍąJ Thank you for pointing that out. It makes sense to me now. Iâm not making excuses, but the tutorials preceding these Code Coaches do not make it clear how to solve these. Thanks again.
+ 1
Tahitiđ·Castillo
Yes there is less information but not very less.
Check this statement "count number of students who pass with 70 points"
So simple you have to count if score >= 70
+ 1
Thank you Simba for that very helpful explanation!
0
AÍąJ Yes but I was referring to the use of the count keyword and variable, which was not covered in the lesson prior to the Code Coach. Iâm not sure it was even covered in earlier lessons.