Home My space log
Language EN (English)

Add in parts

JavaScript Beginner robot ages 11-13 From CS Unplugged

The problem

A quick way to add is to make a ten first. Write a function addInParts(a, b) where a is under 100 and b is under 10. If the last digit of a plus b is MORE than 10, split b to make a ten first, like "(87 + 3) + 4 = 94". Otherwise just write it out, like "75 + 4 = 79". Give back the text.

You will practice: remainder (%), if / else, building text

Mode

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.

      Original challenge · License: 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.