-
Notifications
You must be signed in to change notification settings - Fork 0
Guess the Number
cl4cnam edited this page Jan 16, 2024
·
2 revisions
In this tutorial, you'll learn to program a little well known game "Guess the Number".
Do as in Hello World tutorial except that you change the names: guessTheNumber
, guessTheNumber.html
, guessTheNumber.fg
.
Write these lines into guessTheNumber.fg
:
var numberToGuess := randomIntBetween(1, 100)
var triedNumber := 0
displayNewMessage('Guess my number (between 1 and 100)!')
while triedNumber != numberToGuess:
triedNumber := awaitHumanText()
if triedNumber < numberToGuess:
displayNewMessage('Too low! Try again!')
if triedNumber > numberToGuess:
displayNewMessage('Too high! Try again!')
if triedNumber = numberToGuess:
displayNewMessage('Well Done!')
Note
This is programmed like when you first learned programming! 👍
FuncSug Documentation