Any idea why my hide() function isn't working?

export async function setItems ( itemsArray ) {
$w ( “#repeater1” ). data = [];
$w ( “#repeater1” ). data = itemsArray ;

$w ( “#repeater1” ). forEachItem (( $w , itemData , index ) => {
if ( itemData [ “updatedAirconPrice” ] === undefined ) {
itemData [ “updatedAirconPrice” ] = itemData [ “600012000Btu” ]
}

$w ( “#ServiceName” ). text = itemData . serviceName ;
$w ( “#ServiceRating” ). numRatings = itemData . numberOfRatings ;
$w ( “#ServiceRating” ). rating = itemData . rating ;
$w ( “#ServicePrice” ). text = itemData [ “updatedAirconPrice” ]. toString ();

$w(“#oldPrice”).hide();
$w(“#strikethroughPrice”).hide();
console . log ( "old price: " + itemData [ “oldPrice” ] + " new price: " + itemData [ “updatedAirconPrice” ]);

if ( itemData [ “oldPrice” ] > itemData [ “updatedAirconPrice” ]) {
$w ( ‘#oldPrice’ ). show ();
$w ( ‘#strikethroughPrice’ ). show ();
$w ( ‘#oldPrice’ ). text = "฿ " + itemData [ “oldPrice” ]. toString ();

}
});
}

The lines in red don’t seem to work. Rest works fine, the .show(); functions with the same elements work properly too. Any idea why?

Perhaps it’s because you show them later in the code?

Put a console.log() after the if statement to see if the code showing the two elements is executed:

if(itemData["oldPrice"]>itemData["updatedAirconPrice"]) {
   console.log('show the two elements');

Thank you very much for your reply! I tried that but that wasn’t it. The elements were hidden by default and I changed that which for some reason seemed to do the trick. Thanks for your reply though, much appreciated!