Answer the question
In order to leave comments, you need to log in
How to rewrite the code to get the result without using a loop?
Good day, tell me how you can rewrite this code to get the same result without using a loop (maybe through map or forEach)?
(data is data from the server in the form of an array with objects)
const offers = [];
let _i = 0;
let result;
while (_i < data.length && offers.length < 10) {
result = filters.every((filter) => (filter.value === DEFAULT_VALUE) ? true : FilterRules[filter.id](data[_i], filter));
if (result) {
offers.push(data[_i]);
}
_i++;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question