paul2463 Posted November 10, 2006 Share Posted November 10, 2006 Hello all hopefully you can point me in the right direction, I have this function that turns a string into an array and here is the code:-[code]answer = "Hello, how are you doing";var lettArray = new Array();for (var i=0; i<answer.length; i++) { lettArray.push (answer[i]);}alert(lettArray);[/code]now when i run it in Firefox I get an alert box that says[code],H,e,l,l,o,,, ,h,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g,[/code]as expected, but if I run it using Internet Explorere 6 I get the following[code],,,,,,,,,,,,,,,,,,,,,,,,,[/code]I am pulling my hair out can someone please explain me to me in small words whats happening?? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted November 10, 2006 Author Share Posted November 10, 2006 figured it out, dont know why it worked but it didnew code [code]var lettArray = new Array();for (var i=0; i<answer.length; i++) { lettArray.push (answer.charAt(i)); //notice change here}[/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted November 12, 2006 Share Posted November 12, 2006 Well, the second code snippet should be the only one that works... I'm surprised that FF lets you refer to character positions in a String object like C does. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.