Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Thanked 0 Times in 0 Posts

    Javascript that can flip reverse a sentence

    Not going to lie it is HW for my class. I am suppose write a javascript that would ask user to enter words in a sentece, once done it reverses them.
    I know you can do this by using length property or charAt() method. Or would be easier to use a loop?

    I need help getting this done by today :/

    Attached Thumbnails Attached Thumbnails -1462acb8-4a23-4e97-9cce-905ff20f8053-jpeg  

  2. #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    Thanked 741 Times in 730 Posts
    Use split on the string to create an array of words, then use reverse on the array and then join to put them back together.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts