Displaying content when 2 or more variable conditions are met

Hi all,

I’m trying to get a block to appear when 2 variable conditions are met, but I just can’t seem to get it to work.
Essentially, when I click a button, I want to display a block, but only if another variable is false. So upon clicking a button, it sets a variable (‘viewing_content’) to true, and so long as the other variable (‘retried’) is false, it will display the content. However, if ‘retried’ is true, then the content shouldn’t display.

I’ve set up my logic as follows, and this works fine for the first time the action is triggered (viewing_content = false and retried = false, then viewing_content changes to true). However, when going back in after setting retried = true, the content still appears. I’ve also had a play around with different conditions, but nothing works as expected. Am I trying to do something that can’t be done, or am I fundamentally getting the logic comparison part completely wrong?

Thanks in advance,

Andy

So, I think I’ve figured it out! All I had to do was swap round the variables, so the ‘retried’ variable goes first, instead of second. This essentially blocks the action from happening. But if I’m completely honest, I’m not sure why it works like this! If someone could explain how the variable comparison checks work, I’d really appreciate it, as it doesn’t appear to work on the standard ‘If…then…else’ approach.

Thanks,

It’s tricky to debug properly without being able to see your course but I wonder if the reason might be that you’ve flipped one of the conditions (for the viewing_content variable) when you’ve changed the order?

Hi Matt,

Thank you for responding. Are you able to explain how the condition checking works in principle, particularly when there are multiple variables? That might help me figure out what I’ve done that makes it work (having something work is never good enough for me, I need to know why! :slight_smile: ).

The ‘equal to’ variable comparison check (for Boolean values) is done as a standard JavaScript ‘strict equality’ check i.e. variable === value

I think the problem is more likely to be something else - it’s just really hard to figure out what that is based just on the information here… if you happen to still have a copy of the course with the setup that wasn’t working (or can easily set one up) to share with me I can take a look and try to figure it out for you…

100% agree with this!

Thanks, Matt. I’ve created a duplicate of the course with just the logic part in but now, weirdly, I can’t replicate the issue, either in the duplicate or the original course! Happy to share either with you if you still want to poke around.

Yeah go on DM me a link to the version that should have the issue and I’ll take a look, can’t guarantee I’ll find anything if you can’t replicate the issue any more but I’m still curious to see what’s going on…!