I would like to compare canIBook() with id (increments) in the if statement, but it wont work.
I suspect I can't compare a number with an array, how would i go about fixing this?
The method canIBook() currently returns:
result: [11]
const canIBook = () => {
const no = freeSlotsList.filter((slot) => slot.booked === 1);
const result = no.map((a) => a.id);
return { result };
};
The method with the if-statement:
const renderTableData = () => {
let id = 1;
const activeButton = () => {};
console.log(canIBook());
return (
<tr>
{days.map((val) => (
<td>
{timeSlot.map((n, i) => {
if (id === canIBook()) { //How do i make this true?
return <h1>Works</h1>;
} else {
return (
<button id={id++} className={activeButton}>
{n} {id}
</button>
);
}
})}
</td>
))}
</tr>
);
};