Here's my html element
<div class="rands rando1"></div>
And here's my attempt at styling the element with a variable in the query selector
var selector = 'rando1';
document.querySelector(selector).style.width = "50%";
It throws this error
Uncaught TypeError: document.querySelector(...) is null
<anonymous> http://127.0.0.1:5500/app.js:51
When using querySelector, you have to add the css prefix before.
If it's a class, change your variable to '.rando1'