Created
January 20, 2021 18:52
-
-
Save DavidWells/5b08fa5297429512d9e73c37ab2985a1 to your computer and use it in GitHub Desktop.
Convert string, number to boolean 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
function cleanBooleanParam(value) { | |
switch(value.toString().toLowerCase()) { | |
case "true": | |
case "on": | |
case "yes": | |
case "1": | |
return true; | |
case "false": | |
case "off": | |
case "no": | |
case "0": | |
return false; | |
default: | |
return value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment