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)