Answers for "string false to boolean false javascript"

3

string to boolean javascript

let toBool = string => string === 'true' ? true : false;
// Not everyone gets ES6 so here for the beginners
function toBool(string){
	if(string === 'true'){
      return true;
    } else {
      return false;
    }
}
Posted by: Guest on November-25-2020
0

Convert string to boolean in javascript

var isTrueSet = (myValue === 'true');
Posted by: Guest on July-09-2021
-1

How can I convert a string to boolean in JavaScript?

ES6+
const string = "false"
const string2 = "true"

const test = (val) => (val === "true" || val === "True")
console.log(test(string))
console.log(test(string2))
Posted by: Guest on March-15-2022

Code answers related to "string false to boolean false javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language