What is a function? Coding basics for kids

Posted on May 10, 2021

Coding for beginners is all about learning the fundamentals. When you grasp the building blocks of programming, you and the kids you’re teaching become empowered to think like creative coders and build innovative solutions to real-life problems.

Functions in coding are essential – they’re reusable, adaptable, and incredibly useful. Programming functions are like chameleons because they can do just about anything, which means you’re only limited by your imagination.

Let’s explore what functions can do!

What are functions?

Functions are a building block of coding that exist in every programming language. These dynamic pieces of code are really talented – they can do, well, pretty much anything! By telling a computer to perform a specific task, functions drive code forward.

Functions are sets of code that contain one or more steps to complete a specific action.

Functions are sets of code that contain one or more steps to complete a specific action.

Functions can be small, simple, and straightforward or long, complicated, and multifaceted. They can also hold other functions and various elements of code, such as variables, conditions, and loops.

(P.S. If that sounds like a foreign language to you, we’ve got you covered. Our Camp Coding Camp series covers all of the above and other coding basics for kids.)

Because functions are so flexible and varied, it’s almost impossible to give a nice, neat example that encompasses their full potential. In short, you can create a function that achieves just about anything.

Listen to the whole Coding Songs album here!

Can you create a function that reminds you to brush your teeth every morning? Definitely! Can you create a function that writes your name backward? Sure. Can you create a function that makes a cartwheeling caterpillar appear on-screen whenever you tap the ‘c’ key? If you have the coding skills, you absolutely can!

Functions can be used and reused

One of the best things about functions is once they exist, you can use them, reuse them, and use them some more. They are the ultimate recycling success story!

Functions can contain other code, like variables, loops, and conditions.

Functions can contain other code, like variables, loops, and conditions.

Let’s say you’ve programmed a computer game. When the player scores, confetti cover the screen and congratulatory trumpets chime. You give this celebration function a name – maybe ‘CelebrateWin’. Then, every time you want the confetti to rain and trumpets to roar, you can call upon the ‘CelebrateWin’ function. In other words, you don’t have to write out the individual steps over and over again, saving you valuable time.

Functions in coding are adaptable

Just when you thought functions couldn’t get any more useful, here’s another time-saving feature. Functions can be adapted and tweaked to meet your needs.

Here’s an example. Imagine you’re building an online form that asks users to input their name, email address, and phone number. When a user enters their email address, you need the code to make sure it’s valid. So, you create a function that checks whether the user has included an @ character. You also need to check the validity of the phone number. Instead of creating a brand-new function, you adapt your pre-existing function to check that the phone number field contains digits only – no letters allowed.

It sounds kind of complicated – we know! But our function video for kids breaks it down step-by-step. And there are marshmallows involved. And hot dogs. And robots.

What is coding songs for young learners

Functions can do ANYTHING in coding and help you achieve almost ANY specific task. They can also be reused and adapted. If you are ready to teach kids the basics of coding, dive into our Camp Coding Camp series. We cover all the fundamentals of coding – including functions – in a way that’s fun, accessible, and easy to understand.

Hey there!

Did you know that Scratch Garden has a 2nd Channel? With a growing library of more than 50 videos?

It's all true! We have created a whole other channel on Patreon! Patreon allows creators like Scratch Garden to offer a kind of membership for special fans like you. In exchange for your support, you can access monthly patron-only content like behind-the-scenes videos, Halloween and holiday videos, as well as many hilarious Blooper Videos

For as little as $2/month you can watch all these videos AND help support Scratch Garden to keep making great fun educational content. 

Check out our 2nd Channel to find out more!


Leave a Reply