Can't convert string to number javascript what is wrong with my code? -


var d_long; var d_lat;

a = "37.333941,-121.879065"; var comma = a.search(",");  d_lat = a.slice(0,comma);  d_long = a.slice(comma+1,-1);   math.floor(d_lat); math.floor(d_long);  alert(d_lat + " " + d_long);  var x = d_lat+d_long;  alert(x); 

thanks guys understand doing wrong. try split instead of weird splice. think use d_lat = number(d_lat);

this works:

... var x = number(d_lat)+number(d_long); ... 

see http://www.w3schools.com/jsref/jsref_number.asp


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -