Answers for "parse a string as a boolean 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

string to boolean js

// Everyone does one extra check. Here is a better answer

let toBool = string => string === 'true'; // ? true : false;
// Not everyone gets ES6 so here for the beginners
function toBool(string){
	return string === 'true';
}
Posted by: Guest on April-18-2021

Code answers related to "parse a string as a boolean javascript"

Browse Popular Code Answers by Language