-
(Janet - Zynga Engineer)
Anyone can be a programmer.
-
You just have to be a little bit adventurous,
-
be willing to learn, and have a great idea.
-
To explain functions and parameters,
-
I can use the example of when you order food for lunch.
-
So say you're ordering a sandwich and a drink.
-
Well, the parameters would be
-
what flavor of drink you want and what size sandwich do you want.
-
And so in this way,
-
functions in computers take parameters so that
-
you can specify how big a shape is
-
or what color the shape is.
-
What if we want to draw a bunch of triangles and have
-
their lengths be different sizes?
-
Now you can use our function block and input different numbers
-
so that we can draw different sized shapes.
-
If you click the star on the draw triangle function,
-
you can drag input name into input block;
-
and then if you write
-
length in the spot where it says X and press Enter.
-
You'll create a length input for your function.
-
Then click on the star again to close it out.
-
Now, you'll want to click on the variables category
-
and drag the length block into the move
forward block of your function definition.
-
Drag away the old number block and now
you have a function block
-
where you can input the length of the sides of your triangle.
-
This is called a function with parameters.
-
To use it, click on the functions category
-
and drag out your draw triangle with length function.
-
Now you can use the math block to input different numbers
-
to draw triangles of different sizes.
-
Give it a try in soon you'll be a coding ninja.