The "afraid of the cold" robot

Action functions available :

checkTemperature(); the robot looks at the thermometer
goOut('?'); where '?' = 'no', 'withCoat' or 'withoutCoat'

Test functions available :

lessThan32() which returns true or false
lessThan68() which returns true or false

Warning !!!

Succeed your code with maximum 3 if, no else allowed.

Window to edit your JavaScript code

Test your script

Résult of the execution of your code

Notice: the three executions of your program must be correct without changing your code between them.

The "afraid of the cold" robot

The goal of this exercise is to construct Boolean expressions using AND (&&), OR (||) and / or NOT (!).

You are not to use « else » and since there are just 3 possibilities, it should be possible to achieve this with 3 successive « if » statements and AND (&&), OR (||) and / or NOT (!).

The robot can check the outside temperature and you must ensure that it responds appropriately. If it is colder than 32°F, it shouldn't go out. If the temperature is 32°F or higher and less than 68°F, it should go out wearing a coat. Once it reaches 68°F, it should go out without a coat.

Good work.

◊ ◊ ◊

© Rupert Meurice de Dormale 2017

All rights reserved, reproduction in whole or in part of the interface and / or the code forbidden without the written agreement of the author

The drawings of the robots are of Jean-Baptiste Sonnet.

adresse