Currently, the code is functioning as follows:
var ball = document.getElementById('ball');
//some code
let bml = parseInt(ball.style.marginLeft,10);
//if *conditional statement* is true, do:
ball.setAttribute("style","margin-left:"+(bml-4)+"px;");
However, my attempt to achieve the same result with this code is not working:
ball.style['marginLeft']=bml-4;
Why isn't the result the same? I've noticed that online examples using this method to edit attribute values dynamically often use pre-calculated values like "400px" instead of variables like in my example. Why is that?