Can someone assist me with using a for loop on an array to search for titles? I have a basic ADD TODO form input that submits and adds todos or titles to the array:
todos.push({ title: req.body.add_todo_input, complete: false });
I am pushing user input/todos into the array with this code. Then, I am using EJS to display the result on the webpage <%= todos.title %>
. I thought about implementing a for loop that iterates through the array to add conditional if statements checking if any of the titles in the array match the input. If there is a match, I want to prevent pushing the todos and instead log the message ("Error: TODO already exists")
.