136
rated 0 times
[
143]
[
7]
/ answers: 1 / hits: 15708
/ 12 Years ago, sun, july 29, 2012, 12:00:00
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
.
More From » javascript