Issue
Title more or less sums it up. I'm actually here for the logic: I have a list which has too much items in it and therefore needs to be shortened in this way.
Let's say that I have 2 intervals, 1 starting from today and going back 6months in time, the other one is 6 months ahead in time. I want the items to be listed between these dates: 08-01-2021 until 10-12-2022
P.S. Items have a date object in it so I can cherry-pick them this way.
What would you suggest, and why?
Solution
I don't know if I understood the question correctly but maybe this way:
let start = new Date("08-01-2021");
let end = new Date("10-12-2022");
let newList = [];
makeNewList(){
oldList.filter(item => {
(item.date >= start && item.date <= end;) ? newList.push(item.name) : console.log("Didn't match!");
}
}
Answered By - Zerox
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.