Last active
April 20, 2022 19:48
-
-
Save ZakriaJanjua/27e0713402d2b6d5b765743d69612a0f to your computer and use it in GitHub Desktop.
Robor Systems Coding Challenge Q2
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
const string = "abcdefghijklmnopqrstuvwxyz" | |
function cipher(str, k) { | |
let first = [] | |
let second = [] | |
for (let i = k; i < str.length; i++) { | |
second.push(str[i]) | |
} | |
for (let i = 0; i < k; i++) { | |
first.push(str[i]) | |
} | |
first = first.join("") | |
second = second.join('') | |
return second + first | |
} | |
console.log(cipher(string, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment