Computer Science Canada

Javascript help

Author:  Thuged_Out_G [ Sat Mar 18, 2006 3:43 am ]
Post subject:  Javascript help

what im trying to do is run a string through a function, that will remove all comma's from the string
Also, is there is a way after the string has been stripped of all comma's to change it to an int
similar to turing's strint command

here is what i have come up with so far

code:

function check(var1) {
var comma=new Array[var1.lastIndexOf(",")]
for(i=0;i<=comma.length;i++) {
comma[i]=var1.indexOf(",", i)
}

for(i=0;i<=comma.length;i++) {
var1.substring(comma[i], comma[i] + 1)
}
alert(var1)
}


any help would be appreciated.

Author:  Thuged_Out_G [ Wed Mar 22, 2006 12:43 am ]
Post subject: 

looks like i was realy far off with this problem

code:

var1.split(",").join("")


that did it quite easily


: