I have this function:
function validateVip(){
$("table[id=table-pss] tbody tr").each(function() {
var keval = $(this.cells[4]).find('input');
var data = $(keval[0]).val();
console.log("result: " + data);
console.log(data.includes([vip]));
var x;
if ((data.includes([vip])) == true)
{
x = "yay";
console.log("Vip Exists");
}
else
{
x = "nay";
console.log("No VIP");
}
return x;
});
}
Whenever I call it, it always return "undefined".
Here is how I call the function validateVip:
var isVip = validateVip();
console.log("is vip:" + isVip);
Can someone show me what I did wrong?
Thank you.
returnstatement in yourvalidateVip()functionvipin an array when you dodata.includes([vip])?vipis already an array, and you want to know ifdatais in it, it should bevip.includes(data)datais a string, it can't include an array.