How can I use a ? in a URL to change JavaScript variables?

I can’t figure out how the ? URL separator works, which I need to use for a project.

I made a variable that would alert it’s content when the page was opened, opened the deployment with ?variable=”working”, and expected it to alert working, but instead it alerted what the variable was originally set to.

var variable = "Not Working";
alert(url);