+ 2

Score 70+ (ES6)

Instructions are to use the “for...of...” loop but I am so confused by that that I was trying to solve another way and I still can’t seem to get it right. Any help on what is wrong with my code below would be helpful! CHALLENGE: // 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 started with this and then switched to what I’m more familiar with. for (let a of scores){ return(a); */ for (let x = 0; x >= scores.length) { if (scores[x] < 70) { continue; } if (scores[x] >= 70) { return scores[x]; } x += 1; } } console.log(x);

15th Jan 2021, 10:36 PM
KfMand08
KfMand08 - avatar
10 Respostas
+ 9
KfMand08, look at the code. I can suggest also second way to solve it with filter method. Hope it helps you. https://code.sololearn.com/Wm84TtP63BEx/?ref=app
15th Jan 2021, 11:09 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 5
let scores = [68,95,54,84,77,75,63,74,69,80,71,63] //Please Subscribe to my youtube channel //channel name: Fazal Tuts4U let count = 0; for(let score of scores){ if(score >= 70){ count++; } } console.log(count);
5th Sep 2021, 3:59 PM
Fazal Haroon
Fazal Haroon - avatar
+ 2
let scores = [68,95,54,84,77,75,63,74,69,80,71,63] //Please Subscribe to my youtube channel //channel name: Fazal Tuts4U let count = 0; for(let score of scores){ if(score >= 70){ count++; } } console.log(count); Good Luck
25th Jan 2022, 8:41 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
+ 1
//This is how i made it out /*We Are given an array of numbers so let's create an array out the given array with values greaterhan or equal to 70*/ let scores = [68,95,54,84,77,75,63,74,69,80,71,63] let num = []; for(let scoreAbove of scores){ if(scoreAbove >= 70){ num.push(scores[scoreAbove]); } } console.log(num.length);
20th Dec 2022, 9:28 AM
Kizito David
Kizito David - avatar
0
let list = [68, 95, 54, 84, 77, 75, 63, 74, 69, 80, 71, 63]; var passed = 0; var failed = 0; for (let i = 0; i < list.length; i++) { if (list[i] >= 70) { passed += 1; } else { failed += 1; } } console.log(`passed: ${passed} \nfailed: ${failed}`);
18th Sep 2021, 5:10 PM
Ananth Shetty
Ananth Shetty - avatar
0
let scores = [68,95,54,84,77,75,63,74,69,80,71,63] let passingScores = 0 for (let theNumbersINtheArray of scores) { if (theNumbersINtheArray >= 70) // do the code in curly brackets {passingScores++; // increment passingScores by 1 } } console.log(passingScores)
1st Feb 2022, 10:46 PM
Future
0
let scores = [68,95,54,84,77,75,63,74,69,80,71,63] //your code goes here //create array to save the marks of students who passed var studentsPassed = new Array(); for(let pass of scores){ if (pass >= 70){ //add scores of the passed students to the array studentsPassed.push(pass); } } //output the number of students who passed console.log(studentsPassed.length);
12th May 2022, 8:53 AM
TaskMaster
TaskMaster - avatar
0
let scores = [68, 95, 54, 84, 77, 75, 63, 74, 69, 80, 71, 63]; let newArr = []; for (i = 0; i < scores.length; i++) { if (scores[i] >= 70) { newArr.push(scores[i]); } } console.log(newArr.length);
25th Jun 2022, 11:33 AM
Aref Abdallah
Aref Abdallah - avatar
0
let scores = [68,95,54,84,77,75,63,74,69,80,71,63] let i = 0; for(let result of scores){ if(result > 70){ i++; } } console.log(i);
8th Sep 2022, 6:37 AM
Alexander OKUNRINKOYA