Write a function that accepts an array of test scores as an argument then the function should return a number of scores that 80 or higher? [duplicate]

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Write a function that accepts an array of test scores as an argument then the function should return a number of scores that 80 or higher? [duplicate]



This question already has an answer here:



I'm still pretty new into JS but I'm having a hard time with this problem. I'm sure the answer is somewhat simple but i can't figure out what to put into the function expression after i've made my array of scores? Do i need to do a for loop?
Thanks



let array = [20,30,40,50,60,70,80,92,93,95,98,100]



function testScores(array){



}



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





See generally: stackoverflow.com/questions/3010840/…
– Michael W.
9 mins ago





please add the result as well. do you need all values above or just a single value, the first or the smallest, or what ever?
– Nina Scholz
4 mins ago






2 Answers
2



you can use array's filter method. please follow below definition.


function testScores(array){
return array.filter(ele=>ele>=80)
}





He/She wants the number as output.
– FullStackDeveloper
5 mins ago





btw, testScores is plural.
– Nina Scholz
32 secs ago


testScores


function testScores(array){
return array.filter(number => number >= 80);
}



This will return an array of scores more 80 and above.
e.g


let scores = [20,30,40,50,60,70,80,92,93,95,98,100];
testScores(scores)



If you just want the count of scores more than 80 you can do


testScores(scores).length





He/She wants the number as output.
– FullStackDeveloper
5 mins ago





btw, testScores is plural.
– Nina Scholz
22 secs ago


testScores

Qu,qlS xkFr SFQL6aQoUibVoYl,2N8g0bebgimrV,PzLb Sr1 aV,9JG6l r7r 9,Zn9kcw,F,ovXI,aB2ocopKKn,kVm
Y47jlTMIj1sl7uU0nsmk6e4

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

415 Unsupported Media Type while sending json file over REST Template