-
-
Save Uvacoder/3f96f752ed0f6ce8ebe20f41f1fc02d5 to your computer and use it in GitHub Desktop.
Convert string, number to boolean value
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
| 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