

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Conditionals
incomplete
2: Comparison Operators
incomplete
3: Logical Operators
incomplete
4: Switch
incomplete
5: Ternary Operator
incomplete
6: When to Ternary
incomplete
7: Truthy and Falsy
incomplete
8: Nullish Coalescing
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
A "truthy" value is a value that is considered true when encountered in a Boolean context. In JavaScript, you don't need to explicitly convert a value to a Boolean before using it in a conditional:
if ("hello") {
console.log("hello is truthy");
}
if (42) {
console.log("42 is truthy");
}
// hello is truthy
// 42 is truthy
A "falsy" value works the same way, but for values that evaluate to false:
if (!0) {
console.log("0 is falsy");
}
if (!null) {
console.log("null is falsy");
}
if (!undefined) {
console.log("undefined is falsy");
}
Common truthy values include:
true42 (any number that isn't 0)"hello" (any non-empty string)[] (an empty array){} (an empty object)function() {} (an empty function)Common falsy values include:
false0"" (an empty string)nullundefinedNaN (Not a Number)There's an issue with how Textio checks the number of user credits before sending a message, some users that have negative credits are still able to send messages. A user is expected to have at least one credit to be able to send a message.
Fix the bug on line 5 to correctly check whether the user has enough credits.