In my Laravel blade file, I have an array that I am accessing in JavaScript like this:
var data = {!! json_encode($data) !!};
When I check the console, the variable is displayed as seen here: variable data console print
Additionally, I'm retrieving a form input value using the following code:
$("#add-employeeId").val()
The console displays this form input value like so: form input
Now, I want to verify if the form input exists within the data array. Here's how I'm attempting to do it:
function isInArray(arr, search)
{
return arr.indexOf(search) >= 0;
}
//performing the check
isInArray(data, $("#add-employeeId").val())
However, this validation always returns false even when the value exists. I'd appreciate any insights on what might be causing this issue and what I may be overlooking. Thank you.