854 B
854 B
guess the number activity
Guess the number with math random.
~avatar avatar
@video td/videos/guess-the-number-0
Welcome! This tutorial will help you create a guess the number game! Let's get started!
~
Add an event handler when button A
is pressed.
input.onButtonPressed(Button.A, () => {
})
Create a local variable of type number x
and set it to a random number using pick random
. pick random
9 generates a random number between 0
and 09
.
input.onButtonPressed(Button.A, () => {
let x = Math.random(9)
})
Show the random number on the screen.
input.onButtonPressed(Button.A, () => {
let x = Math.random(9)
basic.showNumber(x)
})
~avatar avatar
Excellent, you're ready to continue with the challenges!