We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Subscriber

Publishers publish, and subscribers subscribe. You might also hear a few alternative terms:

  • Publisher = Producer = Sender
  • Subscriber = Consumer = Receiver

Assignment

Let's further separate the "subscribing" logic from the "distribution" logic.

Complete the doBattles function. It takes a user and an array of moves. It should return an array of pieces, Piece[], that represents the user's pieces that are in battle.

    • Follow the order of the moves array.
    • Include duplicates if they occur (do not deduplicate).