-
-
Save st98/cde3017e0ed38510829e to your computer and use it in GitHub Desktop.
f('hoge', 3) === 'ehog';
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(s, n) { | |
n %= s.length; | |
return s.slice(n) + s.slice(0, n); | |
} | |
function g(s, n) { | |
n %= s.length; | |
return (s + s).slice(n, n + s.length); | |
} | |
function h(s, n) { | |
var r = ''; | |
for (var i = 0; i < s.length; i++) { | |
r += s[(i + n) % s.length]; | |
} | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment