Free Tutorial: Blast Off with JavaScript – A Fun & Galactic Adventure!

create a space coding game in python

Introduction: Hey there, young code-warrior! Are you ready to embark on a galactic adventure that will take your coding skills to the next level? If you’ve dabbled in the world of block coding, it’s time to blast off into the exciting universe of JavaScript! With JavaScript, you can create cool games, interactive websites, and even control robots! Buckle up and hold on tight as we explore this fantastic language with some out-of-this-world examples using Replit.

Why JavaScript? You might be wondering, “Why should I learn JavaScript when there are so many other programming languages out there?” Great question, space cadet! JavaScript is an essential language for web development, and learning it will give you the power to create interactive and dynamic websites that will impress your friends and family!

Setting up Replit:

  1. To get started, open your web browser and go to https://replit.com/.
  2. Log in to your Replit account. If you don’t have one yet, click on the “Sign Up” button in the top right corner and follow the instructions to create a new account.
  3. After logging in, you’ll be taken to your Replit dashboard. Click on the “New Repl” button to create a new project.
  4. In the “Create a Repl” window, select “JavaScript” as the language, and give your project a cool, space-themed name (e.g., “GalacticJavaScript”). Then, click on “Create Repl” to set up your new JavaScript environment.

Mission 1: Console Greetings Let’s start our journey by sending a message to the console, like astronauts communicating with Mission Control!

Type the following code in the Replit editor:

console.log("Greetings, Earthling!");

Now, press the “Run” button, and you’ll see the message “Greetings, Earthling!” appear in the console. Congrats, you’ve just written your first line of JavaScript!

Mission 2: Alien Variables In JavaScript, we use variables to store information. Let’s create a variable to keep track of the number of alien spaceships we’ve spotted:

let alienSpaceships = 5;
console.log("We've spotted " + alienSpaceships + " alien spaceships!");

Run the code, and you’ll see the message “We’ve spotted 5 alien spaceships!” in the console. Remember, variables can change, so we can update the number of spaceships we’ve spotted:

alienSpaceships = 7;
console.log("Update: We've spotted " + alienSpaceships + " alien spaceships now!");

Mission 3: Intergalactic Functions Functions are like reusable command sequences for our spaceship. They help us avoid repeating code and make our programs more organized. Let’s create a function to calculate the distance between two planets:

function calculateDistance(speed, time) {
  let distance = speed * time;
  return distance;
}

let distanceToMars = calculateDistance(100, 24);
console.log("The distance to Mars is " + distanceToMars + " light years.");

Now you know how to create and use functions in JavaScript!

Mission 4: Space Loops Loops help us repeat code, like counting down before launching a rocket. Let’s create a countdown using a “for” loop:

for (let countdown = 10; countdown > 0; countdown--) {
  console.log("T-minus " + countdown + " seconds...");
}
console.log("Blast off!");

Run the code, and you’ll see the countdown from 10 to 1

Here’s a quick recap of the missions we covered:

  1. Console Greetings: Using console.log() to display messages.
  2. Alien Variables: Creating and updating variables.
  3. Intergalactic Functions: Writing reusable functions.
  4. Space Loops: Using “for” loops to repeat code.

These missions provide a beginner-friendly introduction to JavaScript concepts. Encourage the young learner to experiment with the code examples and come up with their own space-themed projects in Replit. This hands-on experience will help them better understand JavaScript and make learning more enjoyable.

Here is the completed code:

// Mission 1: Console Greetings
console.log("Greetings, Earthling!");

// Mission 2: Alien Variables
let alienSpaceships = 5;
console.log("We've spotted " + alienSpaceships + " alien spaceships!");

alienSpaceships = 7;
console.log("Update: We've spotted " + alienSpaceships + " alien spaceships now!");

// Mission 3: Intergalactic Functions
function calculateDistance(speed, time) {
  let distance = speed * time;
  return distance;
}

let distanceToMars = calculateDistance(100, 24);
console.log("The distance to Mars is " + distanceToMars + " light years.");

// Mission 4: Space Loops
for (let countdown = 10; countdown > 0; countdown--) {
  console.log("T-minus " + countdown + " seconds...");
}
console.log("Blast off!");

This code demonstrates the basics of JavaScript, including console output, variables, functions, and loops. Encourage the pre-teen to experiment with these concepts, modify the code, and create their own space-themed projects in Replit to further their understanding of JavaScript.

SHARE WITH FRIENDS >

Dubai, Dubai Coding and math, Dubai, UAE coding and math, Online Math Tutoring (US & Canadian Curriculum) For Expat Families

20 Apr 2026

SAT & AP math prep in Dubai: Virtual strategies, timelines and tutor packages

Dubai, Dubai Coding and math, Dubai, UAE coding and math, Online Math Tutoring (US & Canadian Curriculum) For Expat Families

20 Apr 2026

Dubai math tutor online: Live 1:1 US & Canadian curriculum tutoring for K–12 expat students

Dubai, Dubai Coding and math, Dubai, UAE coding and math, Online Math Tutoring (US & Canadian Curriculum) For Expat Families

20 Apr 2026

How We Match Ivy League & North American Tutors to Dubai Students — Credentials, Interviews, Results

Live Virtual Math Tutoring & Enrichment, Minneapolis

20 Apr 2026

Holiday & Weekend Bootcamps: Intensive Live Virtual Math Prep for Finals and AP/IB Exams (Minneapolis families)

Live Virtual Math Tutoring & Enrichment, Minneapolis

20 Apr 2026

Local Minneapolis Success Stories: Anonymous Case Studies of Virtual Math Tutoring Improving Grades and Confidence

Live Virtual Math Tutoring & Enrichment, Minneapolis

20 Apr 2026

Safety, vetting, and online-classroom best practices for Minneapolis parents choosing virtual math tutors

Live Virtual Math Tutoring & Enrichment, Minneapolis

20 Apr 2026

How much does live virtual math tutoring cost in Minneapolis? (Pricing guide + ROI for college‑track families)

Live Virtual Math Tutoring & Enrichment, Minneapolis

20 Apr 2026

How we measure success: tracking grades, AP/IB scores and mastery with live virtual math tutoring

Live Virtual Math Tutoring & Enrichment, Minneapolis

20 Apr 2026

Live virtual vs in‑person math tutoring for Minneapolis families: pros, cons and when to choose each