Lesson 4 of 21 · Basics
Functions
A statement in on:press is good for one small change. Use fn for more steps. A function can read and write the state of its component.Each statement ends with ;, as in Rust. A form that ends with } needs no ;.Your turn
- Write the function roll. It must add 1 to rolls, and it must set last to Random.int(1, 7).
- Give the function to the button: on:press={roll}.
Preview
1 error
The sandbox needs a browser.