Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Created January 20, 2021 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DavidWells/5b08fa5297429512d9e73c37ab2985a1 to your computer and use it in GitHub Desktop.
Save DavidWells/5b08fa5297429512d9e73c37ab2985a1 to your computer and use it in GitHub Desktop.
Convert string, number to boolean value
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