Javascript examples for Statement:for
write reverse iteration
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w w w . j a v a2s . c o m*/ var name = "this is a test"; var start = "", end = "" for(var i = 0, j = name.length-1; i < j; i++, j--) { end = name.charAt(i) + end start += name.charAt(j) } if (i === j) start += name.charAt(i); console.log(start + end); } </script> </head> <body> </body> </html>