Is there a way in JavaScript to determine if an item already exists in an array? I am using the following code to add items to my array:
const booked_hours = [];
for (let i = 0; i < apptid_set.size; i++) {
const book_hours = [...book_times][i].split(" ");
booked_hours.push(book_hours[2]);
}
//alert(booked_hours);
The code works fine, but I want to ensure that there are no duplicate items in 'booked_hours'. Any suggestions on how to achieve this?