About This Game
This story makes me happy. Two kids need a science fair project. They have no ideas. Then a little brother shows up with a crayon drawing of a robot with googly eyes. And somehow, that terrible drawing becomes the winning entry. Not because it's smart. Because it's creative. Because Sam, the little brother, gives answers like 'McDonald's' when someone asks the capital of the USA. And the crowd loves it.
The coding lesson is about if/else statements. That's how a computer makes decisions. If this, do that. Otherwise, do something else. It's the closest a computer gets to thinking. And it's everywhere. Every app you've ever used has if/else logic running under the surface. When you type a password and it says 'wrong,' that's an if statement. When a game checks whether you hit an enemy, that's an if statement. They're simple. They're powerful. They're kind of the whole point.
I threw in .includes() because it's useful and it feels like magic the first time you see it. Instead of checking if a question is exactly one thing, you check if it contains a word. Does the question have the word 'planet' in it? Then answer the planet question. It's fuzzy matching. It's how real programs handle messy input from real people. People don't type things perfectly. Your code shouldn't expect them to. I guess you could say this lesson is... iffy. I'll show myself out.
But the real lesson is the same one the story teaches. The winning science fair project wasn't the smartest. It was the most creative. Programming is the same way. The best code isn't always the cleverest. It's the code that solves the problem. Sometimes that's elegant. Sometimes that's a cardboard box with googly eyes.
How to Play
Read the story. Root for Sam. When you get to the code, try changing the question and running it again. See which branch the code takes. Add your own questions. Add more else-if blocks. Build your own Incredible Machine that answers anything. The messier the answers, the more fun it is.
Game Details
The Sam character is based on every little sibling who ever ruined everything and somehow made it better. If you know, you know.