0
Super Confused with the Loops and Functions in ES6 Practice Problem
Loops in ECMAScript 6 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. let scores = [68,95,54,84,77,75,63,74,69,80,71,63] //your code goes here I understand how to use a for...of loop, but I can't figure out how to get an incremental to not loop through the array, so it doesn't give me a bunch of 1s and 0s. Would love some help on this.
8 Respostas
+ 2
This is one of the ways.
https://code.sololearn.com/cmREDItb42HS/?ref=app
+ 2
I can't access the code, but I assume it would be something like:
let scores = [68,95,54,84,77,75,63,74,69,80,71,63];
let count = 0;
for(let i = 0; i < scores.length; i++){
if(scores[i] >= 70){
count++;
}
}
console.log(count);
0
I will try to help if you will share your code bit link here for a review
https://www.sololearn.com/post/75089/?ref=app
0
Avinesh can you explain your code? i really need it to undestand more of your code please
0
let scores = [68,95,54,84,77,75,63,74,69,80,71,63]
let count = 7;
//your code goes here
if(scores>=70){
for(let count of scores){
}
};
console.log(count);
well I don't know honestly how this could work but it is succesfull to created expected output
please someone who can create a better code to solve the problem!
i'm sorry for my bad english and my code
I'm still learning(beginner)
0
code from Avinesh
let scores = [68,95,54,84,77,75,63,74,69,80,71,63]
let count = 0;
let newArr = scores.filter(scores =>{
if(scores >= 70){
count++;
return scores
}
});
console.log(count);
this code also create the expected output but you won't use for_of loop. You will only use if statement and give addition to count then you can return scores and return it to console.
sorry if my explanation is hard to get
but hopelly this will help you(at least I tried)
0
https://www.sololearn.com/coach/967?ref=app
Mine is working well with for loop