0Pricing
Javascript for Kids · Lesson

Making Random Numbers

Use Math.random for surprises.

Making Random Numbers is a free Javascript for Kids lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Javascript for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Surprise Time! 🎉

What if the computer could surprise us with a random number? 🎲

Like a magic dice that never stops! ✨

Meet Math.random() 🎰

The spell Math.random() gives a surprise number every time! 🎰

console.log(Math.random());

A Tiny Number 🐜

Notice the number is between 0 and 1, with lots of decimals! 🔢

Like 0.42 or 0.91. It is always a surprise! 😲

Run It Again! 🔁

Press Run a few times. You get a DIFFERENT number each time! 🎲

console.log(Math.random());
console.log(Math.random());

Why So Small? 🤏

The number is always less than 1. That seems tiny! 🐜

But we can make it BIGGER with a little trick. 🪄

Make It Bigger! 📈

Multiply by 10 to get a bigger surprise number! ✖️

console.log(Math.random() * 10);

Even Bigger! 🚀

Multiply by 100 for huge numbers! Try it! 🎆

console.log(Math.random() * 100);

Random Is Fair 🎯

Random means no cheating! Every number has a fair chance. 🤝

That is what makes games exciting! 🎮

Surprises in Games 🎁

Games use random for treasure, monsters, and dice rolls! 🐉

Random keeps things fun and never boring. 🥳

Save the Surprise 📦

We can save a random number in a box to use later! 🎁

let lucky = Math.random();
console.log("Your number: " + lucky);

You Made Magic! 🎉

Great job! Math.random() gives surprise numbers. 🎲

But those decimals are messy. Next we clean them up!

Quick Check 🧠

Question time! 🎯

Random Star! 🏆

Yay! You can make random numbers now. 🎰

Next, we roll a real dice from 1 to 6! 🚀

Frequently asked questions

Is the “Making Random Numbers” lesson free?

Yes — the full text of “Making Random Numbers” is free to read here on the web, and the Javascript for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Javascript for Kids course, upgrade to CoddyKit PRO.

What will I learn in “Making Random Numbers”?

Use Math.random for surprises. You practise Javascript for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Javascript for Kids?

No prior experience is required. Javascript for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Making Random Numbers” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Javascript for Kids lesson?

Yes. Every Javascript for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Making Random Numbers
  2. Rolling a Dice
  3. Picking a Random Item
  4. A Lucky Number Game
← Back to Javascript for Kids