mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 11:08:54 +08:00
re-formate the code
This commit is contained in:
@ -5,7 +5,7 @@
|
|||||||
* @param {String} str2 second input string
|
* @param {String} str2 second input string
|
||||||
* @returns `String` return one alternative arrange string.
|
* @returns `String` return one alternative arrange string.
|
||||||
*/
|
*/
|
||||||
const AlternativeStringArrange = (str1, str2) => {
|
const AlternativeStringArrange = (str1, str2) => {
|
||||||
|
|
||||||
// firstly, check that both inputs are strings.
|
// firstly, check that both inputs are strings.
|
||||||
if (typeof str1 !== 'string' || typeof str2 !== 'string') {
|
if (typeof str1 !== 'string' || typeof str2 !== 'string') {
|
||||||
@ -23,14 +23,14 @@
|
|||||||
let absLenght = firstStringLength > secondStringLength ? firstStringLength : secondStringLength;
|
let absLenght = firstStringLength > secondStringLength ? firstStringLength : secondStringLength;
|
||||||
|
|
||||||
// Iterate the character count until the absolute count is reached.
|
// Iterate the character count until the absolute count is reached.
|
||||||
for(let charCount = 0; charCount < absLenght; charCount++){
|
for (let charCount = 0; charCount < absLenght; charCount++) {
|
||||||
// If firstStringLength is lesser than the charCount it means they are able to re-arange.
|
// If firstStringLength is lesser than the charCount it means they are able to re-arange.
|
||||||
if(charCount < firstStringLength){
|
if (charCount < firstStringLength) {
|
||||||
out_str += str1[charCount];
|
out_str += str1[charCount];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If secondStringLength is lesser than the charCount it means they are able to re-arange.
|
// If secondStringLength is lesser than the charCount it means they are able to re-arange.
|
||||||
if(charCount < secondStringLength){
|
if (charCount < secondStringLength) {
|
||||||
out_str += str2[charCount];
|
out_str += str2[charCount];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user