To read the article online, visit http://www.4GuysFromRolla.com/webtech/code/Right.shtml

Right(string, length): Returns a specified number of characters from the
                       right side of a string
========================================================================

        function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                   return "";
                else if (n > String(str).length)   // Invalid bound, return
                   return str;                     // entire string
                else { // Valid bound, return appropriate substring
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }


Article Information
Article Title: 4GuysFromRolla.com
Article Author: Scott Mitchell
Article URL: http://www.4GuysFromRolla.com/webtech/code/Right.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers