I think that by using a forEach loop, you can decrease the need for using intermediate variables and ease the reading of the algorithm.
"use strict";conststudents=[[18],[16,12,8],[2,12]];students.forEach((grades,index)=>{constrank=index+1;consttotal=grades.reduce((sum,grade)=>sum+grade,0);constaverage=total/grades.length;console.log(`Student ${rank} average is ${average}.`);});// Student 1 average is 18.// Student 2 average is 12.// Student 3 average is 7.
Interesting, I didn't even know it had a name.
Thanks for sharing!
I think that by using a forEach loop, you can decrease the need for using intermediate variables and ease the reading of the algorithm.
What do you think?
Am glad you found it resourceful, Yeah, you are right, thanks so much for sharing