Design comparison
Solution retrospective
I built this a long time ago and I'm currently working on new projects so any help with not allowing the add todo button to add an empty todo would be welcome
Community feedback
- @RiscloverPosted 4 months ago
You could do something like this. It basically takes the trimmed (trimmed meaning spaces are ignored) input value's length. The length being 0 means that the input box is empty, so if it isn't 0, allow the
todoDiv
element to be appended to thelist
element.if (todoInputs.value.trim().length !== 0) { list.appendChild(todoDiv); }
If you have any further questions or if I misunderstood your original question, feel free to let me know!
Marked as helpful2@DeeNue36Posted 4 months ago@Risclover Thank you. Will give this a try immediately and let you know how that turns out
0@RiscloverPosted 4 months ago@DeeNue36 I'm very late with this response, but yay! I'm glad it worked out. No problem.
1 - @Rahmonbek-0001Posted 4 months ago
you have to work a lot with this code
0@DeeNue36Posted 4 months ago@Rahmonbek-0001 I don't understand. Do you mean I have a lot to work on with this code? If that's the case, like I mentioned, it's a really old project, about three years now when I started programming full time. I forgot to submit it and a couple of other challenges
1@DeeNue36Posted 4 months ago@Rahmonbek-0001 It's alright, criticism is welcome. Will definitely retry the challenge should time permit.
0@RiscloverPosted 4 months ago@Rahmonbek-0001 I know you guys already resolved this, but I wanted to add that I think it would be a lot more constructive if, in the future, you gave the person specific examples instead of just simply telling them that their code needs work. :)
2
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord