+ 1
Boolean?
So I'm trying to make a program with js that toggles a var between true and false with a button, and prints true or false to the screen, but I can't get it to work. Can somebody help me? (There's no code to share since I never saved one)
5 Answers
+ 12
Explained in the code
https://code.sololearn.com/Wzxu1DT3f95f/?ref=app
+ 10
It should work..
Showing your code will help a lot.
https://code.sololearn.com/W9Oq60hWWBQJ/?ref=app
+ 1
I was trying
if(boolean variable) {
//code to be executed if var is true
} else {
//code to be executed if var is false
}
but it wouldn't work. Why not?
+ 1
Figured out why it didn't work. Here's the code with a comment explaining my mistake.
https://code.sololearn.com/WSPW5b4j0TML/?ref=app
+ 1
As it turns out, the Javascript course actually explains boolean operators and either I forgot, or it was added in after I completed the course.
But chances are, I forgot. xD



