Created
May 10, 2019 14:30
-
-
Save IOIO72/ba62b2301a83b8d042030e910224f318 to your computer and use it in GitHub Desktop.
Joins two arrays and returns this array or returns a string when the array contains one single value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const joinToArrayOrGetString = (strOrArray1, strOrArray2) => { | |
const ret = [...convertToArray(strOrArray1), ...convertToArray(strOrArray2)].filter(item => typeof item === 'string'); | |
return (ret.length === 1) ? ret[0] : ret; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment