Programming Course for Kids (team management)

Coding course for kids: This coding exercise will help you to learn how to work with JavaScript array, array is a collection variable, whenever we want to store multiple similar type of values in one variable we use array.

coding tutorial for kids

For example if we want to create team, one team can have multiple players, so team can be a array variable.

Let's get familiar with JavaScript coding syntax with real-time example.

Here are the details of the task; we perform each step as described bellow.

  • Create two teams.
  • Add 5 players in each team.
  • Display name of each player on two different boards.
  • Remove the 3rd player from first team and 2nd player from second team.
  • Again display name of each player on two different boards.

Before you start this task, make sure you have gone though the basic coding syntax tutorial (if you are completely new to coding).

Kids Coding Tutorial

Open your Visual Studio Code or anyother SDK you have in your local machine.

Step 1: Create a team A

First we create team and add all our friends, then we count, how many players are there in the team (like we do in school or playground).

To count how many players in team we also use .length property, like in example below we have used team.length

var teamA = new Array();
        teamA.push("Rina");
        teamA.push("Tina");
        teamA.push("Bina");
        teamA.push("Aana");
        teamA.push("Rani");

console.log("Total players in team A "+ team.length);

Learning: Learning: how to create an array and add new element to it, how to find length of an array

Step 2: Create a team B

Now we have to create another team just like above example.

var teamB = new Array();            
    teamB.push("Bhumi");
    teamB.push("Shilpa");
    teamB.push("Anu");
    teamB.push("Bunty");
    teamB.push("Babli");

console.log("Total players in team B "+ team.length);
Step 3: Display all team players name

You probably have seen many sports on television; before game starts, they display all players name on display board, now you need to do the same.

console.log("Team A Players");
for(i=0;i<teamA.length;i++)
{
    console.log(teamA[i]); 
}
    
Team A Players
Rina
Tina
Bina
Aana
Rani
console.log("Team B Players");
for(i=0;i<teamB.length;i++)
{
    console.log(teamB[i]); 
}
    
Team B Players
Bhumi
Shilpa
Anu
Bunty
Babli
Step 4: Remove one player from each team

Now as per the task (instruction above), we need to remove one player from each team from 3rd and 2nd position respectively.

console.log("Team A");

/*
remove 3rd player Bina
which is in index 2,
remove just once.
*/

teamA.splice(2,1)

/*
now again display the list
*/

for(i=0;i<teamA.length;i++)
{
    console.log(teamA[i]); 
}
    
Team A Players
Rina
Tina
Aana
Rani
console.log("Team B");

/*
remove 2nd player Bina
which is in index 1,
remove just once.
*/

teamB.splice(1,1)

/*
now again display the list
*/

for(i=0;i<teamB.length;i++)
{
    console.log(teamB[i]); 
}
    
Team B Players
Bhumi
Anu
Bunty
Babli

Learning: how to remove one element from an array using splice method, we can remove an item using their index number from an array. arrayVar.splice(elementIndex, noOftimes)

Now open your VS Code editor and start practicing JavaScript coding, or look at our next tutorial.

What kids learn from coding tutorial?

This task will give a hands-on experience to kids that help understanding how to write program in JavaScript apart from making them familiar with following JavaScript coding syntax.

kids coding tutorial

Please share this tutorial with your friends and family, we develop more free tutorials for your kids, help us to help them better!

More coding tasks for kids:

 
Teach your kids how to write code!
Coding tutorial for Kids, before your kids join any paid course for learning programming, here are some free tutorials that help them to understand how to write code for real-time programming.
kids coding courses
Coding tutorial for Kids
Kids coding tutorial, free programming tutorial for kids