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.
2 parents 9125172 + b11316b commit 8a34f43Copy full SHA for 8a34f43
Easy/1768. Merge Strings Alternately/solution.js
@@ -6,20 +6,22 @@ function mergeAlternately(word1, word2) {
6
7
// First choose the ith character of the
8
// first string if it exists
9
- if (i < word1.length)
+ if (i < word1.length)
10
+ {
11
result += word1.charAt(i);
-
12
- // second string if it exists
13
- if (i < word2.length)
+
+ }
14
+ if (i < word2.length)
15
16
result += word2.charAt(i);
17
18
19
}
20
21
return result;
22
23
-// Driver code
24
25
let word1 = "abc";
26
let word2 = "pqr";
27
console.log(mergeAlternately(word1, word2));
-//This code is Contributed by chinmaya121221
0 commit comments