Skip to content

Commit 54d469a

Browse files
authored
Create 1844-replace-all-digits-with-characters.js
1 parent a9b1314 commit 54d469a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} s
3+
* @return {string}
4+
*/
5+
const replaceDigits = function(s) {
6+
let arr = s.split('')
7+
for(let i = 1; i < s.length; i += 2) {
8+
arr[i] = shift(s[i - 1], +s[i])
9+
}
10+
11+
return arr.join('')
12+
13+
function shift(ch, x) {
14+
return String.fromCharCode(ch.charCodeAt(0) + x)
15+
}
16+
};

0 commit comments

Comments
 (0)