Hiding elements based on dataset value

Hey there,

On my site, users use sliders to award themselves points. Once they reach a certain number of points the text on their ‘badge’ changes to reflect. I’ve done this using the below code in the backend.

What I’m also trying to do is hide a vector image (revealing their new badge) on a single page. I think where I’m stuck is all of my below if statements are in the backend and I’m not sure how to write the code that pulls that data from the dataset and effects the vector image for a single page.

export function NewUserData_afterQuery(item, context)

{
if (item.sum <= 250 ) { item.badge = “Brand New” ;}
if (item.sum > 250 ) { item.badge = “Beginner” ;}
if (item.sum >= 8500 ) { item.badge = “Serious” ;}
if (item.sum >= 16500 ) { item.badge = “Legendary” ;}

return item;}

This is what I have so far … I’m pretty sure I’m wildly off the mark … please don’t mock me too much, I’m a complete coding novice …

export function NewUserData_afterQuery(item, context)
{

if ((item.badge).text === “Beginner” ) {$w( “#vectorImage62” ).hide();}

return item;}