GM Wixers: Not able to reference a variable

export function validatew(items) {
//Add your code for this event here:
console.log(“items”, items)
let itempw = items;
console.log(“item values:”, itempw);
if ( $w(‘#iInput1’).value === itempw) {
console.log(“Paging to Services page”);
validity = “yes”
wixLocation.to(‘/services’);
} else
{
validity = “no”
}

}
In this code value to this function is passed thru a higher level function via ‘items’. When it is referenced to display it is displaying correct values. But when the same is used in ‘IF’ statement it is not comparing though both sides are equal. Always going to ‘ELSE’ part. Is any wise wixers can help on how to referencing the variable in the IF statements?

Is there anyone who can help with this problem?

Try to console.log a typeof of both $w(’ #iInput1 ').value and itempw to see if they are really equal and of the same type.

You’re using “===” for the equality check, which checks if those are the same object references, and not just that the values that they hold are equal. If “items” is an array, you might want to loop over the array contents and check that every item is equal to the corresponding item in the other array