Write JavaScript codes that count how many As, Bs, Cs in the following scores array, and calculate the average of the scores (Note: you can’t hard code the computation) A range >=90; 90>B range >=80; 90> C range >=70
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
var arr=[88,76,75,80,99,100,96,72];
var total=0,aCount=0,bCount=0,cCount=0;
for(i=0;i<arr.length;i++){
if(arr[i]>=90)
aCount++;
else if(arr[i]>=80)
bCount++;
else if(arr[i]>=70)
cCount++;
total=total+arr[i];
}
alert("A's: "+aCount+"\nB's: "+bCount+"\nC's: "+cCount+"\nAverage:
"+(total/arr.length));
}
</script>
</body>
</html>
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Get Answers For Free
Most questions answered within 1 hours.