Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,3 +1,18 @@
|
|||
var a = "cat".split("");
|
||||
a.reverse();
|
||||
print(a.join("")); // tac
|
||||
//using chained methods
|
||||
function reverseStr(s) {
|
||||
return s.split('').reverse().join('');
|
||||
}
|
||||
|
||||
//fast method using for loop
|
||||
function reverseStr(s) {
|
||||
for (var i = s.length - 1, o = ''; i >= 0; o += s[i--]) { }
|
||||
return o;
|
||||
}
|
||||
|
||||
//fast method using while loop (faster with long strings in some browsers when compared with for loop)
|
||||
|
||||
function reverseStr(s) {
|
||||
var i = s.length, o = '';
|
||||
while (i--) o += s[i];
|
||||
return o;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue