And what about the middle?

The middle needs to stay above the bottom. Please find the code attached to see the core conditional logic put together.

JAVASCRIPT
OUTPUT
Results will appear here.