Advertisement
dhshin

practice_9

Jun 26th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let n = 10;
  2. let scores = [];
  3.  
  4. for(let i = 0; i < n; i++)
  5.   scores.push(Math.random() * 100);
  6.  
  7.  
  8. let min, max, sum = 0;
  9.  
  10. min = max = scores[0];
  11.  
  12. for(let i = 0; i < n; i++) {
  13.   if(min > scores[i]) min = scores[i];
  14.   if(max < scores[i]) max = scores[i];
  15.   sum += scores[i];
  16. }
  17.  
  18. console.log(scores);
  19. console.log('최소 점수: ' + min);
  20. console.log('최대 점수: ' + max);
  21. console.log('평균 점수: ' + sum / n);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement