Boolean 4/4
Simple Applications of Boolean() Function
We can pass expressions to the Boolean function to check whether itβs true or false. For example, the following code checks if the number passed to the Boolean() function is completely divisible by 3. It returns true if the value is completely divisible by 3 and false otherwise.
1console.log(Boolean(21%3 == 0));
But without Boolean() we also get the same result. But Boolean function gives more clarity that Boolean value must return.
1console.log(21%3 == 0);
Summary
- Boolean values are either
trueorfalse. - The first letter of Boolean values (true and false) should be written in uppercase.
- The
Boolean()method is used to evaluate an expression and returns true or false based on results.
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain why we use the Boolean() function if the result is the same without it?
What are some other examples where Boolean() is useful?
Can you clarify the note about writing Boolean values with an uppercase first letter?
Awesome!
Completion rate improved to 2
Boolean 4/4
Swipe to show menu
Simple Applications of Boolean() Function
We can pass expressions to the Boolean function to check whether itβs true or false. For example, the following code checks if the number passed to the Boolean() function is completely divisible by 3. It returns true if the value is completely divisible by 3 and false otherwise.
1console.log(Boolean(21%3 == 0));
But without Boolean() we also get the same result. But Boolean function gives more clarity that Boolean value must return.
1console.log(21%3 == 0);
Summary
- Boolean values are either
trueorfalse. - The first letter of Boolean values (true and false) should be written in uppercase.
- The
Boolean()method is used to evaluate an expression and returns true or false based on results.
Thanks for your feedback!
single