Advertisement
Spocoman

03. Numbers

Nov 7th, 2023
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function numbers(input) {
  2.     let numbers = input.split(' ').map(Number).sort((a, b) => b - a);
  3.     let average = (numbers.reduce((a, b) => a + b, 0) / numbers.length);
  4.     let top5 = numbers.filter(n => n > average).slice(0, 5);
  5.  
  6.     console.log(top5.length == 0 ? "No" : top5.join(' '));
  7.     return;
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement