Boolean inside function help

Could someone show me an example of this in work with actual value in the place of wasThatTrue. I cannot conceptualize these questions in their current form. I understand how this works I just want to see a real-life example with values in if anyone has time. Thanks

  **Your code so far**

function trueOrFalse(wasThatTrue) {
// Only change code below this line
if(wasThatTrue){
return "Yes, that was true"
}
return "No, that was false";

// Only change code above this line

}
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.123 Safari/537.36

Challenge: Use Conditional Logic with If Statements

Link to the challenge:

How about this?

wasThatTrue= 5;
function trueOrFalse(wasThatTrue) {
  if(wasThatTrue> 10){
    return "Yes that was true";
  }
  return "No that was false";
}
console.log(trueOrFalse(wasThatTrue));

Without the “>”, the if statement is a simple true or false, like you would use to output an error or other information based on a true/false value

if (err) {
return err;
} return data;
}
1 Like

Perfect explanation, Thanks.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.