-1

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

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

 function testScores(array){

 }
Brian Thomas
  • 101
  • 3
  • 10

2 Answers2

0

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

function testScores(array){
 return array.filter(ele=>ele>=80)
}
Manoj
  • 1,175
  • 7
  • 11
0
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
emmatope
  • 1
  • 2