Skip to content

Commit 7d57f7f

Browse files
authoredMar 28, 2022
merge: cache repeated function calls (#962)
1 parent 27ae62e commit 7d57f7f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

Diff for: ‎Ciphers/Atbash.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const Atbash = (str) => {
1111
}
1212

1313
return str.replace(/[a-z]/gi, (char) => {
14+
const charCode = char.charCodeAt()
15+
1416
if (/[A-Z]/.test(char)) {
15-
return String.fromCharCode(90 + 65 - char.charCodeAt())
17+
return String.fromCharCode(90 + 65 - charCode)
1618
}
1719

18-
return String.fromCharCode(122 + 97 - char.charCodeAt())
20+
return String.fromCharCode(122 + 97 - charCode)
1921
})
2022
}
2123

0 commit comments

Comments
 (0)