JS analysis method analysis of string flipping

This example analyzes the method of js to implement string flipping. Share to everyone for reference, specifically:

1. Complete flip of strings:

  VAR STR = "smile AT life "; Document.write (Str.Split ("). Reverse (). Join (""));  
The result is:

2. Invert the word order in the string, but the word alphabetical order is unchanged:

Function ReverStr (param) {var arr = param.split (“”); var newarr = []; for (i = 0; i
  <arr.length;i++){
newArr[arr.length-i] = arr[i];
}
return newArr.join(" ");
}
document.write(reverseStr("smile at life"));

 
operation results :

Attached: Input string reverse operation complete example

 www.jb51.net JS reverse string   var str = prompt ("Please enter any string:"); var Ar = new array (str.length); var i = str.Length-1; var j = 0; while (i> = 0) {Ar [j] = str.Charat (i); i-; j ++; } Document.write ("Follow is: "); for (j = 0; J  [1    
Here <str.length;j++) { document.write(aR[j]); } online HTML / CSS / JavaScript code running tool : http: // Tools. JB51.NET/code/htmljsrun test, can be run as follows:
PS: Here you recommend one Online Tools for Higher Reference:

Online Text Remorse Randol Sort Tools:

http://tools.jb51.net/aidedDesign/flipped_txt JS实现字符串翻转的方法分析

More about JavaScript Related Content Interested readers can view this topic: “JavaScript Mathematical Computing Summary”, “JavaScript Data Structure and Algorithm Skill Summary”, “JavaScript Action Skills Summary”, “JavaScript event related Operation and Skills Daquan, “JavaScript Operation DOM Skill Summary” and “JavaScript Character and String Operation Skill Summary”

JS实现字符串翻转的方法分析 I hope this article will help you JavaScript programming.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment