I want the text to be printed without commas.
<html> <head> <title>Reverse</title> </head> <body> <form name="rev"> Enter the string : <input type="text" name="str"/> <input type="button" value="click" onclick="rev1()" /><br> reverse of given string : <input type="text" name="res"/> </form> <script type="text/JavaScript"> function rev1(){ var a=rev.str.value; var b=[]; var i,j=0; for(i=a.length-1;i>=0;i--){ b[j]=a[i]; j++ } //rev.res.value=b; alert(b); } </script> </body> </html> If I give the input as abc I am getting an output as c,b,a, but I want it as cba.
[].toString()is implemented as[].join()(which uses a comma as a separator, by default, ie[].join(',').