This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
How to make this block more efficient?
Post Flair (click to view more posts with a particular flair)
Post Body
I am trying to improve bits of code on different repos I've worked on and noticed this block
Object.values(data).forEach((value) => {
for (let i = 0; i < todosList?.length; i ) {
if (
value === todosList[i].title ||
value === todosList[i].description
) {
setData({
...data,
error: "A todo exists with that title or description",
});
match = true;
return;
}
}
});
if (match) {
return;
}
It's running a forEach and a for loop but is there a way to cut out either one so it becomes more efficient? This should basically be checking the todosList object and see if there are any matching titles or descriptions and if there are, it will let the user know it has been used already.
Author
Account Strength
100%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
9,114
Link Karma
553
Comment Karma
8,165
Profile updated: 2 days ago
Posts updated: 1 month ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...