Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function numbers(input) {
- let arr = input.trim().split(' ')
- .map((x) => parseInt(x));
- if (arr.length < 5) {
- console.log('No');
- }
- let average = arr.reduce((a, b) => a + b) / arr.length;
- let result = arr.filter((x) => x > average)
- .sort((b, a) => a - b)
- .slice(0, 5)
- .join(' ');
- console.log(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment