I'm quite new to programming.
My use case : I want to find elements that matches this criteria (refer code sample below) as well as elements that doesn't match the criteria and store them in 2 separate variables. Is there any simple methods to do it?
Also I am not able find elements that returns false here. Can someone help me with this.
posts = response.data.posts.filter((m) =>
m.post.toLowerCase().includes(searchQuery.toLowerCase())
);
Do, you want something like this?
let res = [{name: "Peter", age: 29}, {name:"Joseph", age: 23}, {name: "Lily", age: 17}, {name: "Robert", age: 33}, {name: "Ralph", age: 49}]
let temp1=[];
let temp2=[];
res.map((item) => item.age <=25 ? temp1.push(item) : temp2.push(item));
console.log(temp1);
console.log(temp2);