In this next example, let’s create a Doctors’ Availability Schedule by using the or, >, and < buttons.

Add a Radio/Dropdown input to the new calculator, and create six radio buttons with all the names of the days in a week.

The output will show the names of doctors who are available on a selected day.

Using the Script Helper, select your output button and click on the if button.

Replace condition by clicking your input button, select the < button, type number 2, select the or button, followed by your input button again, the > button, and then type the number 5.

Replace true with "Dr. Au" and false with "Dr. Hale".

After clicking Done, your codes should look like this:

'use strict'; return { doctor: inputs.days<2 || inputs.days>5? "Dr. Au": "Dr. Hale", };

Your output should display this:

The or (||) operator returns the value true when one or both of the expressions are correct.

Sunday is given the value 1 and the number goes on in ascending order until 7, for Saturday.

Dr. Au is working on Sunday, Friday, and Saturday. So when the input is less than 2 (1 = Sunday) or when the input is more than 5 (6 = Friday, 7 = Saturday), the output displays ‘Dr. Au’, otherwise Dr. Hale is available, who is on duty for the rest of the days.

Did this answer your question?