Last active
February 22, 2020 14:31
-
-
Save LukeMwila/144ae71e1b2918661100335b0ab7c7eb to your computer and use it in GitHub Desktop.
Function that checks if parameter is an array that contains strings
This file contains hidden or 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 checkIfArrayOfStrings = (arrayToCheck: any): boolean => { | |
if (arrayToCheck && arrayToCheck instanceof Array && arrayToCheck.length) { | |
const arrayOfNonStringValues = arrayToCheck.filter((value: any) => { | |
return typeof value !== 'string'; | |
}); | |
return arrayOfNonStringValues && arrayOfNonStringValues.length | |
} | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment