← JavaScript 1 Guide JavaScript 1 · Practice
JavaScript 1 Practice

Use it. Then build it.

Start with small changes, then gradually do more yourself. If you get stuck, use the toolbox or open a hint. The goal is not memorising everything at once.

Beginner? Start at Challenge 1. The support slowly disappears as you get stronger.
Experienced? Try the Quick Check. If it is easy, jump to the Mastery Challenge and Bonus Lab.
Toolbox

JavaScript 1 Patterns

Here is one complete program so you can see how the pieces fit. Need one skill while practising? Copy just that pattern.

Complete example See how the pieces fit
<script>

let answer = prompt("What is 2 + 2?");

if (answer == 4) {
    alert("Correct!");
} else {
    alert("Try again!");
}

</script>
How to use this Not an answer sheet
Try the exercise first. If you forget the shape of a command, copy only the pattern you need and adapt it to your problem.
VARIABLE
let name = "Daniel";
PROMPT
let answer = prompt("Question?");
ALERT
alert("Hello!");
JOIN
alert("Hello " + name + "!");
MATHS
let area = length * width;
IF / ELSE
if (answer == 4) { alert("Correct!"); } else { alert("Try again!"); }
Experienced? Start Here

Quick Skill Check

Try these without the toolbox. If all four are easy, skip ahead.

1. GreetingAsk a name and alert Welcome NAME!.
2. MathsStore 8 and 6, multiply them, alert the answer.
3. DecisionAsk What is 4 + 5? and respond Correct / Wrong.
4. ComparisonAsk for a score. Unlock at 100 or more.
Your code
ResultNothing runs until RUN
Core Practice

Gradually take off the training wheels

The early exercises give you more help. Later ones make you remember and combine the same skills yourself.

Challenge 1 · Modify

Personal Welcome

Lots of support

The program already works. Make it yours.

Goal
Ask nameWelcome NAME to Dino Run!
Starter code
ResultChange the final message
Change only the final alert so it says something like Welcome Daniel to Dino Run!
Challenge 2 · Complete

Finish the Greeting Machine

Still guided

Now one important line is incomplete.

Starter code
GoalUse the variable
Hint
What variable did you store the player's name in?
Challenge 3 · Build from comments

Game Profile

Medium support

The comments tell you what each line should do. You write the JavaScript.

Target behavior
Ask nameAsk favourite gameShow both in one alert
Your code
ResultExample: Daniel likes Minecraft
Need a nudge?
You need two prompt() lines and one alert().
Challenge 4 · Maths

Area Calculator

Medium support

Most of the structure is there. You decide the calculation.

Starter code
Result5 × 4 should give 20
Challenge 5 · Comparison Symbols

Fill in the missing symbol

Quick logic check

Choose the symbol that matches each rule. No full program yet.

Choose from: ==   !=   <   <=   >   >=
score ___ 100The level unlocks at 100 or more.
lives ___ 0Continue if lives are not equal to 0.
age ___ 10Only players younger than 10.
Check answers
score >= 100

lives != 0

age < 10
Challenge 6 · Complete if / else

Unlock the Level

Less support
Starter code
Rule100 or more unlocks it
Challenge 7 · Debug

Repair the Broken Quiz

Read code carefully

This is not about memory. It is about spotting what looks wrong.

Broken code
GoalMake the quiz run
What kind of mistakes?
Look for quotes and brackets. Also compare the if line with the toolbox.
Challenge 8 · Build from requirements

Secret Word

Almost independent
Your program must:
  • ask for a secret word
  • store the answer
  • use if / else
  • say ACCESS GRANTED if correct
  • say ACCESS DENIED otherwise
Your code
ResultYou choose the password
Need the structure?
let answer = prompt(...)

Then use if (...) { } else { }.
JS 1 MASTERY

Build a Guessing Game

Now put the main JavaScript 1 skills together with very little help.

Requirements
  • choose a secret number
  • ask the player to guess
  • store the guess
  • use if / else
  • alert a correct or wrong message
Your game
ResultCan someone else play it?
Hint 1
You need prompt, a variable and if / else.
Hint 2
let guess = prompt(...);

if (guess == ...) {

} else {

}
Bonus Lab · Experienced Coders

Same skills, more interesting combinations

These do not require new JavaScript. They require more planning.

Bonus A

Two-question quiz

Ask two questions and check each answer separately.

Bonus B

Mission admission

Ask the player's name and score, then decide whether the mission unlocks.

Bonus C

Choose a route

Make a tiny branching story using prompt, variables, if/else and alert.

Bonus A · Build

Two-question Quiz

Ask two questions. Check each one with its own if / else. Make the questions your own.
Your code
ResultNo starter code
Bonus B · Logic

Mission Admission

Target behavior
Ask nameAsk score100+ acceptedunder 100 train more
Your code
ResultUse both variables
Bonus C · Creative

Choose a Route

Ask the player to choose something such as forest or mountain. Give a different outcome for each choice.
Your code
ResultYour mini story
JavaScript 1 complete

If you can build the guessing game without copying a full solution, you are ready for JavaScript 2 and controlling actual HTML elements.