We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6aa1e44 commit 1900229Copy full SHA for 1900229
javascript/2810-faulty-keyboard.js
@@ -0,0 +1,23 @@
1
+/**
2
+ * @param {string} s
3
+ * @return {string}
4
+ */
5
+var finalString = function (s) {
6
+ // initialize empty string str
7
+ let str = "";
8
+
9
+ // loop thorugh the every character of string s
10
+ for (let i = 0; i < s.length; i++) {
11
12
+ // if every character of string is i then reverse the previous string character and store in string str
13
+ if (s[i] == 'i') {
14
+ str = [...str].reverse().join('');
15
+ } else {
16
+ // else add every character of string s with str and store in string str
17
+ str += s[i];
18
+ }
19
20
21
+ // return string str
22
+ return str;
23
+};
0 commit comments