JSFiddle - React, Tailwind, and code Playground

HTML

<div id="myDiv">
</div>

JavaScript

var toBoolean = function(value) {
    var strValue = String(value).toLowerCase();
    strValue = ((!isNaN(strValue) && strValue !== '0') &&
        strValue !== '' &&
        strValue !== 'null' &&
        strValue !== 'undefined') ? '1' : strValue;
    return strValue === 'true' || strValue === '1' ? true : false
};


var output = '';
output += 'true = ' + String(toBoolean(true)) + '<br>';
output += '"true" = ' + String(toBoolean('true')) + '<br>';
output += '"True" = ' + String(toBoolean('True')) + '<br>';
output += '1 = ' + String(toBoolean(1)) + '<br>';
output += '"1" = ' + String(toBoolean('1')) + '<br>';
output += '100 = ' + String(toBoolean(100)) + '<br>';
output += '"100" = ' + String(toBoolean('100')) + '<br>';
output += 'false = ' + String(toBoolean(false)) + '<br>';
output += '"false" = ' + String(toBoolean('false')) + '<br>';
output += '"False" = ' + String(toBoolean('False')) + '<br>';
output += '0 = ' + String(toBoolean(0)) + '<br>';
output += '"0" = ' + String(toBoolean('0')) + '<br>';
output += 'null = ' + String(toBoolean(null)) + '<br>';
output += '"null" = ' + String(toBoolean('null')) + '<br>';
output += 'undefined = ' + String(toBoolean(undefined)) + '<br>';
output += '"undefined" = ' + String(toBoolean('undefined')) + '<br>';
output += '"" = ' + String(toBoolean('')) + '<br>';

console.log(output);
document.getElementById('myDiv').innerHTML = output;