Module 2 · In your browser · challenge 2 of 2 in this lesson

safeAmount returns value when it is a positive number

A code cell with the real Luau runner grades it. No Studio needed.

Open

Level 2, Builder

Challenge

Write safeAmount(value, fallback) in the cell below using an if expression and typeof. Passing the tests completes this challenge.

Start from
The Run cell below
Check it here
Run the code cell; the challenge completes when it passes. No Studio needed.

Done means

  • safeAmount returns value when it is a positive number
  • Text, nil, zero and negative numbers return fallback
  • All five assertions pass
Luau
Ctrl Enter runs the cell. Checked by tests