Здравейте. Кодът работи ,но judge дава 20/100.
https://judge.softuni.org/Contests/Practice/Index/2474#2
02. Programming Fundamentals Mid Exam
function solve(input){
let averageValue = [...input];
averageValue = averageValue.reduce((a, b)=> a + b,0)/ input.length;
let numsGreaterThan = [];
for(let i = input.length; i >= 0;i--){
let currentNum = input[i];
if( currentNum > averageValue){
if(numsGreaterThan.length < 5){
numsGreaterThan.push(currentNum);
}
}
}
numsGreaterThan = numsGreaterThan.sort((a,b)=> b - a);
if(numsGreaterThan.length == 0){
console.log("No");
}
else{console.log(numsGreaterThan.join(" "));}
}
Много благодаря!