Skip to content

Changing and swapping values

Read · 1 of 5

Updating a box

score = score + 5; reads score, adds 5 and stores it back. It's so common there's a shortcut: score += 5;.

Adding or taking away exactly 1 has an even shorter one: score++; and score--;.