PDA

View Full Version : Writing a program that displays what you've entered backwards



ThatJediDude
May 13th, 2011, 05:08 PM
Hi everyone, new here.

I'm trying to write a program that displays what a user has entered, it processes it, and displays it backwards

This is what I have so far,


<script type="text/javascript">
var input ("Please enter a sentance","")

So really this is what it needs to display.
"The sentance you entered are "Hi people""
"The sentance in REVERSE order are "elpoep iH"

If anyone can help, it would be awesome, since I'm a noob at this.

ThatJediDude
May 13th, 2011, 06:39 PM
Thanks mate, but I can't do it that way. Teacher's orders. I've attached a pic of what its suppose to look like.

ryan7745
May 13th, 2011, 07:32 PM
Hello,
turn the input into an array get the length and do a for loop i.e the for loop looks like
for (i=array.length,i>0,i-1) that will make it loop backward through the array. Then just print the input to the screen. so mytext += array[i];
Hope this helps.

rnd me
May 13th, 2011, 07:33 PM
alert("hello world".split("").reverse().join(""));