< Return to Video

CS Fundamentals: How to Create a Simple Function

  • 0:05 - 0:10
    You've already learned to use and edit
    functions as a part of an efficient
  • 0:10 - 0:16
    program. Now, let's learn how to create
    and use a function from scratch. To do
  • 0:16 - 0:21
    this, look for the category called
    functions in the toolbox. Here, you'll see
  • 0:21 - 0:26
    a block called "do something". Drag that
    block out into your workspace and rename
  • 0:26 - 0:31
    it to something new that better
    describes what your function will do. I'm
  • 0:31 - 0:37
    calling this one "make a square". From here,
    you can drag blocks into the function to
  • 0:37 - 0:45
    specify what you want to happen when the
    function is used. With our function
  • 0:45 - 0:50
    created, you can see that a new make a
    square block appears under the functions
  • 0:50 - 0:56
    label in the toolbox, so that we can
    actually use, or "call", our created function
  • 0:56 - 1:01
    from our program. This is an important
    step that's easy to forget. Okay, time to
  • 1:01 - 1:09
    continue on and get creative with your
    own functions!
Title:
CS Fundamentals: How to Create a Simple Function
Description:

more » « less
Video Language:
English
Team:
Code.org
Project:
CSF '21-'22
Duration:
01:13

English subtitles

Revisions