Five binary cards have 16, 8, 4, 2 and 1 dots. A card is either showing its dots (W, white) or turned over (B, black). Write a function binaryCards(n) for a number from 0 to 31. It gives back five letters for the cards, biggest first. Example: 11 is 8 + 2 + 1, so it gives "BWBWW".
You will practice: binary numbers, loops, if / else, building text
Press Tab to indent. Press Esc and then Tab to move on to the next button.
Your code runs in your browser. We do not receive it or save it.
Test results
What your code printed
CC BY-SA 4.0
Adapted from a CS Unplugged programming challenge by the University of Canterbury Computer Science Education Research Group, licensed CC BY-SA 4.0.
Changes: Rewritten in our own words as a function with tests, hints and steps, in Python and JavaScript, by Open Cosmos. This version is also CC BY-SA 4.0.
Accessibility settings
Change how Open Cosmos looks and moves. Your choices are saved only in this browser.