+ 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.

14th Feb 2022, 3:11 AM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
8 Respostas
+ 4
You can declare another variable to count the students who have higher marks than 70 and print it outside loop.
14th Feb 2022, 3:44 AM
Simba
Simba - avatar
+ 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)
14th Feb 2022, 5:07 AM
Simba
Simba - avatar
+ 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);
14th Feb 2022, 3:48 AM
AÍąJ
AÍąJ - avatar
+ 1
Ok. Thank you Simba . I will try that.
14th Feb 2022, 3:45 AM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
+ 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.
14th Feb 2022, 4:02 AM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
+ 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
14th Feb 2022, 4:32 AM
AÍąJ
AÍąJ - avatar
+ 1
Thank you Simba for that very helpful explanation!
14th Feb 2022, 4:56 PM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar
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.
14th Feb 2022, 4:36 AM
Tahiti🌍Castillo
Tahiti🌍Castillo - avatar