Join Class

Coding Course for Kids (dummy fund distribution)

Coding tutorial for kids: These tasks will help you to improve functional thinking and logic building ability of your kids, also help them to get familiar with JavaScript coding syntax with real-time example.

Coding Course for Kids

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

Here are the coding exercise for kids.

  • Create a team for fund raising
  • Create a Cashbox
  • Raise fund from people.
  • Create a list of needy people,
  • Distribute all the money among them equally
  • Congratulate every team members for their effort
Free Coding courses for Kids

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

Create a file with name “fund-distribution.js” (you can give any name)

Inside code, whenever we write something with double forward slash (// comment), or within (/* comment */)are comment, means non-functional text, not code

Step 1 : Create Team

Create a team, write all your friends name (replace the existing name), you can increase the list if you have more friends, notice index number will always starts from zero (0), not one (1).

/*creating array and adding element using index, index starts with zero.*/
var team = new Array(); 
team[0] = "Akshay";
team[1] = "Arnold";
team[2] = "Shiva";
team[3] = "Amir";
team[4] = "Monica";
console.log("Team Members:"+ team.toString());

Learning: How to define array and add element using array index number.

Step 2 : Create cashbox

Create a cashbox, assign zero (0), initially no money.

Whenever we declare a variable in JavaScript, we use either var or let, those are keywords.

// declaring a variable and assigning a value
var cashBox=0;

Learning: How to define a variable and assign value at the same time. VariableName =Value

Step 3 : Create donor list and get collection

Let’s assume we have 50 donors, who are contributing to fund raising; assuming everyone giving amount between 1 to 99 INR (or any currency).

var numberOfDonors =50;
// creating array of fix number
var donors = new Array(numberOfDonors);
var receivedMoney;
    receivedMoney=Math.floor(Math.random() * 100);
    cashBox = cashBox+ receivedMoney;

console.log("Total Collection : "+ cashBox);

Learning: How to define array with fix number of element, declaring variable, using for loop, JavaScript math function, increment the value of any variable.

Now we know how much total fund we have for distribution.

Step 4 : Create list of needy people

Notice, here again we create a list of people, means list object, like earlier list, but this time we create list object differently.

var needyPeople = new Array();


// keep on adding people to the list
console.log("total needy people "+ needyPeople.length);

Learning: How to create array and add element using push method in JavaScript.

So now we know how much total fund we have and how many needy people are there, let’s calculate how much money each person will get.

var totalNeedyPeople=needyPeople.length;
console.log("total needy people "+ totalNeedyPeople);

// so each person will get 
var eachPersonMoney = eval(cashBox / totalNeedyPeople);

console.log("each person will get "+ eachPersonMoney);

Learning: Finding array length property, how to use eval function and how to divide a number by another number.

Step 5 : Distribute the fund among them

Now we know how much each person will get, and the list of needy people, simply distribute among them.

// simple for loop example
    console.log("Hello "+ needyPeople[i] + ", please accept " + eachPersonMoney + " Rs.");

Learning: How use for loop to extract value from array using index number.

Step 6 : Congratulate all team members

Already we have team variable, which has all team member name stored.

// using forEach loop, calling a function


function congratulateMember(member, index) {
    console.log("Congratulation "+ member);

Learning: How to write a function and call from array foreach loop in JavaScript.

kids coding task

Benefit of this coding exercise

This simple exercise will help kids to develop their logical thinking and understanding the coding flow apart from following technical aspect.

More importantly, kids will learn how a big task can be splitted into small tasks.

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

Trying following programming tasks

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