она распечатана для меня весь массив.
Код: Выделить всё
// Exampel data
const numbs = [7, 100, 107, 4000, 6, 73];
// Main function
var filter = function (arr) {
let fill = [];
for (let i = 0; i < arr.length; i++) {
if (fn(arr[i])) {
console.log("Before pushing to fill: "+arr[i])
fill.push(arr[i])
console.log("After pushing to fill: ")
}
}
return fill;
};
console.log("From the filter function: "+filter(numbs));
// Sub function
function fn (number_from_arr) {
let res=[];
for (let i = 0; i < number_from_arr.length; i++) {
if (number_from_arr[i] > 100) {
res = number_from_arr[i]
}
}
return res;
}Подробнее здесь: https://stackoverflow.com/questions/795 ... oesnt-sort