Reverse a string-freecodecamp-js topic

Source: Internet
Author: User

Reverse a string (flip string)
  1. Title Requirements:
      • Convert a string to an array
      • Flipping the array order with the reverse method of the array
      • Convert an array to a string
  2. Ideas:
    • Use. Split (") to convert a string into an array of single letters
    • Use. Reverse () to invert the array
    • Concatenate array elements into strings using. Join (')
  3. The code is as follows:
    1.   
        1  function   reversestring (str) {  2  //  Please write your code here   3  var  temp = [];   4  temp = Str.split (""   5  temp = Temp.reverse ();   6  str = temp.join (""   7  return   STR;   8  }   9  10  reversestring ("Hello"); 

  4. RELATED LINKS
    • . Split () Method: http://www.runoob.com/jsref/jsref-split.html
    • . Reverse () Method: http://www.runoob.com/jsref/jsref-reverse.html
    • . Join () Method: http://www.runoob.com/jsref/jsref-join.html

Reverse a string-freecodecamp-js topic

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.