"if" Statement Parameters Not Functioning As Intended. Javascript
The following JavaScript 'if' statement is not reading the parameters as I intended both parameters to be read. When I shoot bulletOne with a function that uses an interval to run
Solution 1:
So first of all you made a typo that is why it doesnt work in your failed attemps.
Your variable is named bulletOne
but you do your if statement with bulletOneLeft
.
Also :
style.left;
return a string, so you have to do use parseFloat function or parseInt if you're sure it will always be an int (https://www.w3schools.com/jsref/jsref_parsefloat.asp, https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/parseInt) as following :
var bulletOne = parseFloat(document.getElementById("bulletOne").style.left;
And you are good to go I believe.
Post a Comment for ""if" Statement Parameters Not Functioning As Intended. Javascript"