Describe your issue in detail here.
What am I missing here?
Your code so far
function trueOrFalse(wasThatTrue) {
// Only change code below this line
if(trueOrFalse) {
return "Yes, that was true";
}
if(trueOrFalse) {
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/118.0.0.0 Safari/537.36
Challenge Information:
Basic JavaScript - Use Conditional Logic with If Statements
you did it exactly right, except you are testing the wrong variable in the if statement.
i would reccomend manually typing everything early on rather than copy-pasting it from the lesson, it makes you rely on yourself more and also forces you to learn better ways to type code in the editor!
to fix your code, just replace every instance of the variable trueOrFalse into wasThatTrue.
in both if statements, you were checking the value of a variable called trueOrFalse, when you actually never defined it neaither as a variable or as a parameter.
the variable you are supposed to use is wasThatTrue, put that in between the brackets beside your if statements, and it should totally work.
function trueOrFalse(wasThatTrue) {
// Only change code below this line
if(trueOrFalse) {
return “Yes, that was true”;
}
if(wasThatTrue) {
return “No, that was false”;
}
// Only change code above this line
}
That’s my code what might be the problem with it?
The directions say
" Create an if statement inside the function to return Yes, that was true if the parameter wasThatTrue is true and return No, that was false otherwise."
Where are you getting trueOrFalse from in this line?
if(trueOrFalse)
You should only be checking wasThatTrue. You should only be using one if statement as well. If you do this
if(wasThatTrue) {
return “Yes, that was true”;
}
if(wasThatTrue) {
return “No, that was false”;
}
Notice how the if statements are checking the exact same thing? Do you know how you can return the false statement without putting it inside the if statement?
function trueOrFalse(wasThatTrue) {
// Only change code below this line
if(trueOrFalse) {
return “Yes, that was true”;
}
if(trueOrFalse) {
return “No, that was false”;
}
// Only change code above this line
}
that the code
look at the response it keeps on bringing…
// running tests
trueOrFalse(false)
should return the string
No, that was false
// tests completed
Where might I be going wrong? I’m really confused.
Why are you still trying to use trueOrFalse in the if statements?
wasThatTrue is what you need to use. Forget about trueOrFalse. You are still trying to use two if statements when you need just one. So, lets take this one step at a time. What would your code look like if you only wanted to return “Yes, that was true”. We can start there and make sure thats right then we can add on the second step
If thats your first if statement still its not correct. After the ending } for the if statement try just returning the false statement and see what happens. If you have not yet you still need to change the above.
Its not correct…even if you get the false response code correct you are still not using the correct variable in the if statement which I have pointed out multiple times. It will not pass if you try using trueOrFalse instead of wasThatTrue