Solution for Understanding Boolean Values

Solution for Understanding Boolean Values
0.0 0

#1

It took me some time but the answer I cam up with was:
function welcomeToBooleans() {

// Only change code below this line.
if( 1+3 === 4);

return true; // Change this line
}

It passed but I wonder if this was the right answer for this problem. Can anyone tell me if it’s truly okay to use this answer. Thanks.


#2

Be careful with the semicolon here, as this can lead to confusion. While this is valid syntax, this is essentially an empty if-statement, similar to

if (1 + 3 === 4) {
  // empty!
}

#3

Thanks for pointing that out. I’ll do better with my syntax next time around. Take care.


#4

Here is mine:

function welcomeToBooleans() {
// Only change code below this line.
if (5+5 === 10) {
return true;
} else {
return false; // Change this line
}
// Only change code above this line.
}


#5

All the challenge asks you to do is return true.

function welcomeToBooleans() {
  return true;
}

Also, note that you don’t need to use if...else if you want to return a boolean value based on some conditional:

function sumEqualsTen(a, b) {
  return a + b === 10;
}

sumEqualsTen(5, 5); // true
sumEqualsTen(1, 9); // true
sumEqualsTen(1, 2); // false