vasil-y-vasilev

Numbers TEST 3

Jul 5th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function numbers(input) {
  2.  
  3.     let arr = input.trim().split(' ')
  4.         .map((x) => parseInt(x));
  5.  
  6.     if (arr.length < 5) {
  7.         console.log('No');
  8.     }
  9.     let average = arr.reduce((a, b) => a + b) / arr.length;
  10.  
  11.     let result = arr.filter((x) => x > average)
  12.         .sort((b, a) => a - b)
  13.         .slice(0, 5)
  14.         .join(' ');
  15.  
  16.     console.log(result);
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment