Learn with tiles › 34
Passing values
Pass a value when you call a function, so that it works differently each time.
1
The count in the brackets next to the function name is a parameter. It is a variable that receives the value passed when the function is called.
If you call stars(2), count becomes 2 and two stars appear. The same function works differently depending on the value passed.
To do Call the function stars once more so that three stars (***) appear on the third line.
Loading tiles…
2
Inside the function, you use a parameter like a variable. If you tap a slot inside the function, the parameter appears under Variables in ▾.
Right now the function greet says Hello, friend to everyone. Fix it so that it greets with the name it receives.
To do Make Hello, Lara and Hello, Nyang appear, one per line.
Loading tiles…
3
There can be several parameters. Write them separated by commas, and pass the values in the same order when you call.
If you call multiply(2, 3), a becomes 2 and b becomes 3.
To do Call the function once more so that 7 x 8 = 56 appears on the second line.
Loading tiles…