// #1
Object.entries('reversed string').sort((a,b)=>b[0]-a[0]).map(a=>a[1]).join('');
// #2
'reversed string'.split('').reduce((a,c)=>c+a);
// #3
[...'reversed string'].sort(_=>-1).join('');
// #4
[...(function() {
const str = new String('reversed string');
str[Symbol.iterator] = function() {
return {
value: this,
index: this.length,
next: function() {
return {value: this.value[--this.index], done: typeof this.value[this.index] == 'undefined'}
},
}
}
return str;
})()].join('')
-
Notifications
You must be signed in to change notification settings - Fork 0
neomasterr/dumb-ways-to-reverse-string-in-js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published