Skip to content

Commit ae74e6b

Browse files
reformatted the code with the standard.js code style
1 parent 713ab61 commit ae74e6b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

String/AlternativeStringArrange.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Alternative arrange the two given strings in one string in O(n) time complexity.
22

3-
// Problem Source & Explanation: https://www.geeksforgeeks.org/alternatively-merge-two-strings-in-java/
3+
// Problem Source & Explanation: https://www.geeksforgeeks.org/alternatively-merge-two-strings-in-java/
44

55
/**
66
* Alternative arrange the two given strings in one string in O(n) time complexity.
@@ -9,37 +9,36 @@
99
* @returns `String` return one alternative arrange string.
1010
*/
1111
const AlternativeStringArrange = (str1, str2) => {
12-
1312
// firstly, check that both inputs are strings.
1413
if (typeof str1 !== 'string' || typeof str2 !== 'string') {
1514
return 'Not string(s)'
1615
}
1716

1817
// output string vlaue.
19-
let out_str = "";
18+
let outStr = ''
2019

2120
// get first string length.
22-
const firstStringLength = str1.length;
21+
const firstStringLength = str1.length
2322
// get second string length.
24-
const secondStringLength = str2.length;
23+
const secondStringLength = str2.length
2524
// absolute length for oparetion.
26-
let absLenght = firstStringLength > secondStringLength ? firstStringLength : secondStringLength;
25+
const absLenght = firstStringLength > secondStringLength ? firstStringLength : secondStringLength
2726

2827
// Iterate the character count until the absolute count is reached.
2928
for (let charCount = 0; charCount < absLenght; charCount++) {
3029
// If firstStringLength is lesser than the charCount it means they are able to re-arange.
3130
if (charCount < firstStringLength) {
32-
out_str += str1[charCount];
31+
outStr += str1[charCount]
3332
}
3433

3534
// If secondStringLength is lesser than the charCount it means they are able to re-arange.
3635
if (charCount < secondStringLength) {
37-
out_str += str2[charCount];
36+
outStr += str2[charCount]
3837
}
3938
}
4039

4140
// return the output string.
42-
return out_str;
41+
return outStr
4342
}
4443

45-
module.exports = AlternativeStringArrange;
44+
module.exports = AlternativeStringArrange

0 commit comments

Comments
 (0)