We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fbcc54c commit dcdbdc8Copy full SHA for dcdbdc8
Ciphers/RailFenceCipher.js
@@ -1,20 +1,20 @@
1
function railFenceCipher(text, rails) {
2
- if (rails <= 1) return text;
+ if (rails <= 1) return text
3
4
- const fence = Array.from({ length: rails }, () => []);
5
- let rail = 0;
6
- let direction = 1;
+ const fence = Array.from({ length: rails }, () => [])
+ let rail = 0
+ let direction = 1
7
8
for (const char of text) {
9
- fence[rail].push(char);
10
- rail += direction;
+ fence[rail].push(char)
+ rail += direction
11
12
if (rail === 0 || rail === rails - 1) {
13
- direction *= -1;
+ direction *= -1
14
}
15
16
17
- return fence.flat().join('');
+ return fence.flat().join('')
18
19
20
-module.exports = railFenceCipher;
+module.exports = railFenceCipher
0 commit comments