Workshop › Angry Birds-style Slingshot › Step 44 of 47
After a win, next() starts the next level with the score kept, or starts over after the last one. After a loss, the
score goes back to 0 and the same level starts again. The top line shows the level number.
```js
function next() {
if (state === 'won') level === LEVELS.length - 1 ? reset() : startLevel(level + 1)
else if (state === 'lost') {
score = 0
startLevel(level)
}
}
ctx.fillText('Level ' + (level + 1) + ' Birds ' + birdsLeft + ' Score ' + score, 10, 22)
```LEVELS.length - 1 is the number of the last level (2 when there are 3).(level + 1) is in brackets so it is added as numbers before being joined to the text; people count from 1.next as shown.draw, put 'Level ' + (level + 1) + ' in front of the Birds text.Skills: Game states
← Start any level The best score →