I’m trying to give the element a random width of 1 – 100% but this isn’t working.
document.querySelector(".box").style.width = Math.floor((Math.random() * 100) + 1)%;
>Solution :
You need to concatenate % as a string:
document.querySelector(".box").style.width = Math.floor((Math.random() * 100) + 1) + '%';