function trueOrFalse(wasThatTrue) {
// Only change code below this line
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/97.0.4692.99 Safari/537.36
Challenge: Basic JavaScript - Use Conditional Logic with If Statements
if statements are used to make decisions in code. The keyword if tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses. These conditions are known as Boolean conditions and they may only be true or false.
When the condition evaluates to true, the program executes the statement inside the curly braces. When the Boolean condition evaluates to false, the statement inside the curly braces will not execute.
At the very least, if you have read the lesson and watched the video, you should be able to identify which part of the code is the “if statement”. Its the thing that says ‘if’.
Do you see the keyword if anywhere in your code? You need to use if since this lesson is about if.
I’m trying to understand what you do and do not understand. Me rewriting the entire lesson for you could end up doing nothing to help you if I don’t understand what you do and don’t know.
You might be moving too fast if you covered this much material in 1 day.
In this challenge, there is an example with a function called test. Can you find that example? Where is it?
Inside of that example, the if keyword is used. Can you identify the lines that use the if keyword and the if statement?
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
function trueOrFalse(wasThatTrue) {
// Only change code below this line
if (wasThatTrue) {
return "Yes, that was true";
}
return "No, that was false";
}
test(true);
test(false);
// Only change code above this line
}