Double points
ChallengeKeeping count
On a bonus level, everything the hero collects is worth double. This script should work out the score, but it gets it wrong.
What should happen
- The hero has 12 coins and 3 gems. That is 15 things.
- Everything is doubled.
- The score is 30.
| Things | The sum | Score |
|---|---|---|
| 12 coins and 3 gems | (12 + 3) × 2 | 30 |
What happens now
The script writes Score: 18 in the log. It doubled the gems, but not the coins.
| What the script does | The sum | Score |
|---|---|---|
| Times first: 3 × 2 is 6. Then 12 + 6 | 12 + 3 × 2 | 18 |
How to fix it
The plus has to be done before the times. You know how to make that happen.
- Press Code, at the top left of the code box, if it is not picked already.
- Find the line that starts
@score is. - Put a bracket before
@coinsand another after@gems.
Test it
Press Run. The goal under the code box gets a tick when the score is 30.
| If the log says | What to check |
|---|---|
| Score: 18 | The brackets are missing |
| A red note under the script | A bracket is missing its partner. Every ( needs a ) |

