JavaScript : Boolean Expressions III


  1. Construct Boolean expressions using the AND, OR and NOT operators.

 Your Task, Your Challenge 

Le robot faiseur de puzzle

Write your code so that the robot puts the pieces in the right places.

By carefully arranging the tests in order to differentiate the pieces, you can enable the robot to complete the puzzle correctly.

There are 4 tests available to do this:

  1. circular() checks whether the piece is circular or not;
  2. square() checks whether the piece is square or not;
  3. allBlue() checks whether the piece is solid blue or not;
  4. solidYellow() checks whether the piece is solid yellow or not.

 Relevance of criteria above all 

In this exercise, the only difficulty is in choosing the right criteria to use in order to identify one piece at a time and eliminate the two pieces that must be grouped and thrown in the trash.

As with the other exercises in this chapter, the use of « else » is not allowed. Since there are five different locations to differentiate, 5 successive « if » statements should work.

Now all you have to do is write your code using the correct syntax and you'll be all set…

Refer to the chapter on theory just before this one if this is not yet clear to you.

Good luck!