Hi,
I have been working on a script, and I ran into yet another scripting curiosum (for me at least).
I made this little test to show...
Now if I do my math correctly, I would expect the result to be 108 (9*12) but instead it comes to 918 (9*102)?
It of course has to do with line 10 in my script, where I expected distance to become 12 (the value of item.TAL_2 + 2) not 102??
I tried changing the script so I could run it as a normal Javascript in Chrome, and here it comes out with 108 - so what am I missing?
Best regards from Denmark
Kasper
Solved! Go to Solution.
The distance is coming in as a string. This code:
distance + 2
is concatenating "2" to the string "10", thus "102". What you need to do is convert distance to an integer. You should be able to say
distance = Number(distance);
at the top of the function to fix this. You might want to do the same to the speed variable just in case.
Here's a little explanation I did in a firefox console
Can't find what you're looking for? Ask the community or share your knowledge.