CSP Unit 4 Lesson 5: Conditionals Explore

The wrap up for this unit asks students to answer the following question:
“Can a computer evaluate an expression to something between true and false? Can you write an expression to deal with a “maybe” answer?”
https://studio.code.org/s/csp4-2022/lessons/5/levels/2?login_required=true

I feel really dumb right now, but what would you say is the answer here? I feel like it is a very simple “no”, but maybe I am wrong? I can’t find the answer in the lesson plan.
Thanks!

1 Like

Greetings @cedgar.

Well if were talking about a simple boolean expression you could do something like test if the boolean is neither true nor false or a number is out of range… perhaps a visual of what I’m demonstrating may help out

var needCredentials = undefined; // by default var initialization is undefined
if(needCredentials === true) { // forces value to be a bool comparison
// force user to sign in
} else if (needsCredentials === false) {
// we need this one because your testing for edge cases here
} else {
// here's probably where all the maybe go though this seems
// like a pretty essential parameter for any site so this condition
// may result in an error being thrown if the user didn't account
// for it
}

Anyways that’s my interpretation to such, a comparison can always evaluate something to true or false. However, you can write a maybe answer from being able to evaluate from those statements

My best Example would be “Guess Who?”, you have to ask boolean questions to get all the maybes from that one comparison, since we still don’t know we will have to continue asking until we get a definitive answer to win which means expressions can go beyond the scope of just true and false

I think it’s up to interpretation but i hope this helps

1 Like