Lesson 40 of 49 beginner

Build Your First Mini App

From Zero to Running Code

Open interactive version (quiz + challenge)

Real-world analogy

Building your first app is like assembling a paper airplane. You fold one crease at a time (write one line at a time), check the shape as you go (run and debug), and eventually launch it across the room (execute the program). It won't be a Boeing 747 — but watching YOUR creation fly for the first time is unforgettable!

What is it?

A mini app is a small, self-contained program that does one useful thing. Today we're building a console app that stores a user's name, checks the time of day, and prints a personalized greeting. It uses variables, string concatenation, if/else logic, and console.log — the essential building blocks of every program ever written.

Real-world relevance

Every massive app started as something tiny. Facebook started as a simple profile page. Google started as a search box. Your mini app is the first step on that same journey. The skills you learn here — variables, strings, conditionals — are used in EVERY programming language and EVERY application.

Key points

Code example

// My First Mini App: The Greeter!
// Save this as greeter.js and run: node greeter.js

// Step 1: Store the user's info in variables
const userName = "Alex";
const userAge = 25;
const currentHour = new Date().getHours(); // 0-23

// Step 2: Create a greeting based on time of day
let greeting;

if (currentHour < 12) {
  greeting = "Good morning";
} else if (currentHour < 18) {
  greeting = "Good afternoon";
} else {
  greeting = "Good evening";
}

// Step 3: Build the message using template literals
const message = `${greeting}, ${userName}! You are ${userAge} years old.`;
console.log(message);

// Step 4: Add some fun conditional logic
if (userAge < 13) {
  console.log("Wow, you're starting young! Future coding prodigy!");
} else if (userAge < 18) {
  console.log("Awesome! You're ahead of most adults!");
} else if (userAge < 30) {
  console.log("Perfect time to learn — your career will thank you!");
} else {
  console.log("It's never too late — many great devs started after 30!");
}

// Step 5: A simple counter
console.log("\nLet's count to 5:");
for (let i = 1; i <= 5; i++) {
  console.log(`  ${i}...`);
}
console.log("Blast off! You just wrote a real program!");

Line-by-line walkthrough

  1. 1. Comment: The name of our mini app!
  2. 2. Comment: How to save and run this file
  3. 3.
  4. 4. Comment: Step 1 — creating our data
  5. 5. Creating a constant variable to store the user's name as text
  6. 6. Creating a constant for the user's age as a number
  7. 7. Getting the current hour (0-23) from the computer's clock
  8. 8.
  9. 9. Comment: Step 2 — time-based greeting
  10. 10. Declaring 'greeting' with let because we'll change its value below
  11. 11.
  12. 12. Checking if it's before noon (hour 0-11)
  13. 13. If true, set greeting to morning
  14. 14. 'else if' checks another condition — is it before 6 PM?
  15. 15. If true, set greeting to afternoon
  16. 16. 'else' catches everything else — must be evening/night
  17. 17. Set greeting to evening
  18. 18. Closing the if/else block
  19. 19.
  20. 20. Comment: Step 3 — building the output message
  21. 21. Using template literals (backticks) with ${} to insert variables into text
  22. 22. Printing the complete personalized message!
  23. 23.
  24. 24. Comment: Step 4 — more conditional fun
  25. 25. Checking if user is under 13
  26. 26. Print an encouraging message for young learners
  27. 27. 'else if' for teenagers (13-17)
  28. 28. Encouragement for teens
  29. 29. 'else if' for young adults (18-29)
  30. 30. Career-focused encouragement
  31. 31. 'else' for everyone 30 and over
  32. 32. Motivation for career changers
  33. 33. Closing the if/else block
  34. 34.
  35. 35. Comment: Step 5 — a simple loop
  36. 36. A blank line for visual spacing in output
  37. 37. A 'for' loop: start at 1, go while i<=5, add 1 each time
  38. 38. Print each number with formatting
  39. 39. Closing the loop
  40. 40. A celebratory final message — you did it!

Spot the bug

const userName = "Alex"
const greeting = "Hello, " + username;
consol.log(greeting);

if userName === "Alex" {
  console.log("Welcome back!");
}
Need a hint?
Look at variable name spelling, the console command, and the if statement syntax...
Show answer
Three bugs! 1) 'username' should be 'userName' (JavaScript is case-sensitive!). 2) 'consol.log' should be 'console.log' (missing the 'e'). 3) The if statement needs parentheses: if (userName === "Alex"). These are the three most common beginner mistakes!

Explain like I'm 5

You know how you can tell Alexa or Siri to do things? 'Hey Siri, what's the weather?' Building a mini app is like teaching Siri a new trick. You write the instructions: 'When someone tells you their name, say hello to them!' Your program listens, thinks, and responds — just like a tiny robot friend you built yourself!

Fun fact

The 'Hello, World!' tradition started in 1978 with the book 'The C Programming Language' by Brian Kernighan. Since then, virtually every programming tutorial begins with it. You're now part of a tradition that's almost 50 years old!

Hands-on challenge

Create a file called myapp.js and build your own greeter! Change the userName to YOUR name, add more if/else conditions (maybe check if the name is long or short, or add a favorite color variable). Run it with node myapp.js. Then change values and run again — see how the output changes!

More resources

Open interactive version (quiz + challenge) ← Back to course: Full-Stack Playbook