In this example for the and button operator, let’s create a calculation to understand how the and (&&) operator works.

Name your calculator “John: I need a pen and a paper, please.”

Add two checkbox inputs and name them “Here, have a pen.” and “Here, have a paper.” respectively. Add a value output and name it “John’s answer”.

Using the Script Helper, on line 4, click on your output button.

Select if, and replace condition by clicking your input pen button, then the == button, followed by typing true.

Continue with selecting the and button, your input paper button, the == button, and typing true.

Then, replace true with “Thank you.” and false with “I need both paper and pen.”

After clicking Done, your codes should look like this:

'use strict'; return { answer: inputs.pen == true && inputs.paper== true? "Thank you.": "I need both paper and a pen.", };

Your output should display this:

The and (&&) operator displays the true command when both checkboxes are ticked (both inputs carry true value).

When only one of the checkboxes is ticked, the output will display the false command.

So, the output will display “Thank you.” because John needs both pen and paper, otherwise it will show “I need both paper and pen” because John doesn’t get both of what he needs.

Did this answer your question?