Course Content
Introduction to JavaScript (staging)
Introduction to JavaScript (staging)
Boolean 3/4
The Boolean()
Function:
The Boolean()
function, in JavaScript, is used to return or convert a value to its Boolean value i.e., true
or false
.
Almost any value is evaluated as true
if it has some sort of content, for example.
let name="paul"; console.log(Boolean(name));
As you can see for the above variable, name
we get the output as true because it had a string value. An empty string would have given a false
output.
Task
Use the Boolean method to check wheater the value given to the variable emptyString
is true
or false
. Show the answer on the console.
As you can see now for an empty string it gave the output as false
.
Thanks for your feedback!
Boolean 3/4
The Boolean()
Function:
The Boolean()
function, in JavaScript, is used to return or convert a value to its Boolean value i.e., true
or false
.
Almost any value is evaluated as true
if it has some sort of content, for example.
let name="paul"; console.log(Boolean(name));
As you can see for the above variable, name
we get the output as true because it had a string value. An empty string would have given a false
output.
Task
Use the Boolean method to check wheater the value given to the variable emptyString
is true
or false
. Show the answer on the console.
As you can see now for an empty string it gave the output as false
.
Thanks for your feedback!
Boolean 3/4
The Boolean()
Function:
The Boolean()
function, in JavaScript, is used to return or convert a value to its Boolean value i.e., true
or false
.
Almost any value is evaluated as true
if it has some sort of content, for example.
let name="paul"; console.log(Boolean(name));
As you can see for the above variable, name
we get the output as true because it had a string value. An empty string would have given a false
output.
Task
Use the Boolean method to check wheater the value given to the variable emptyString
is true
or false
. Show the answer on the console.
As you can see now for an empty string it gave the output as false
.
Thanks for your feedback!
The Boolean()
Function:
The Boolean()
function, in JavaScript, is used to return or convert a value to its Boolean value i.e., true
or false
.
Almost any value is evaluated as true
if it has some sort of content, for example.
let name="paul"; console.log(Boolean(name));
As you can see for the above variable, name
we get the output as true because it had a string value. An empty string would have given a false
output.
Task
Use the Boolean method to check wheater the value given to the variable emptyString
is true
or false
. Show the answer on the console.
As you can see now for an empty string it gave the output as false
.