The letter-sorter robot

Résult of the execution of your code

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

Action functions available :

goToBox('which'); where 'which' = 'Mail', 'yellow', 'red' or 'green'
letter('do'); where 'do' = 'take' or 'put'

Test functions available :

aLetterInPincer () which returns true or false
letterHeldYellow () which returns true or false
letterHeldRed () which returns true or false

Test your script

Window to edit your JavaScript code

The letter-sorter robot

The goal of this exercise is to be able to correctly nest a conditional structure in a repeating loop.

Each day, the mail carrier puts a stack of letters into the mailbox. The envelopes come in three different colors – yellow, red and green. The robot must sort each letter into the box with the same color as the envelope. At the end of the program, the robot must return to the mailbox to be ready for the next day. Note, it is possible that on some days the mail carrier will not put any letters into the mailbox – so the robot will begin its task even though the mailbox is empty.

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