Common functions in JavaScript (entry level) (continuous update)

Source: Internet
Author: User

Maple Bamboo Dream In this article introduces some of the most commonly used functions of the entry level in JavaScript, and it is a very useful function for children's shoes that have gone through the introduction. If you find any problem, please discuss it.

List of issues

Q1:

Design a function repeatIt(str, n) , enter a string str and an integer n, return a string consisting of n str, and return "not a stirng" if Str is not a string. For example, repeatIt("furzoom", 2) "Furzoomfurzoom" is returned. Go to A1.

Q2:

Design a function digitChar(n) , enter a non-negative integer n, and return an array containing the number of integer n from low to high. For example, digitChar(123) returns [3, 2, 1]. Go to A2.

Q3:

Design a function nameSwap(name) , enter the name, the first and last names are separated by a space, the first and last names are exchanged and returned, still separated by a space. For example, nameSwap("Ma Yan") return "Yan Ma". Go to A3.

Problem solving

A1:

function Repeatit (str, n) {  return typeof str = = = = = "string"? Array (n + 1). Join (STR): "Not a string";}

Go to Q1.

A2:

function Digitchar (n) {  return (n + "). Split ("). Map (number). reverse ();

Go to Q2.

A3:

function Nameswap (name) {  return Name.split ("). Reverse (). Join (');}

Go to Q3.

Common functions in JavaScript (entry level) (continuous update)

Related Article

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.