← ACARA Digital Technologies Years 7–8

Visual blocks to JavaScript: say, ask and variables

Blocks have typed JavaScript equivalents: a say block becomes console.log, an ask block becomes prompt, and a set variable block becomes let (or an assignment with =).

Understanding Visual blocks to JavaScript: say, ask and variables in ACARA Digital Technologies Years 7–8

What it does: Set variable blocks create a variable and give it a value. In JavaScript, let creates the variable and = stores the value. The variable already exists, so you only reassign it with =. Writing let again would try to declare it a second time. A say block shows a message, so it becomes console.log. prompt is for asking the user a question. The answer from prompt() is stored by putting it on the right of an = sign, with the variable name on the left. JavaScript has no built-in say(). It would cause a ReferenceError, so use console.log("Hello!"); instead.

Common mistakes: say is a block name, not a JavaScript function. An ask block becomes prompt, so the line should be let name = prompt("Name?");. set is the word on the block, not JavaScript. A set variable block becomes let, so the line should be let score = 0;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 562–580) and word search (Modules 522–580).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which JavaScript is the typed version of a 'say Hello' block?
console.log("Hello");prompt("Hello");
Matches
say("Hello!");
↓
say is the name of a block, not a JavaScript function. The typed version of a say block is console.log().
Applying
Meanings
Term
console.log, prompt, let
Meaning
Blocks have typed JavaScript equivalents: a say block becomes console.log, an ask block becomes prompt, and a set variable block becomes let (or an assignment with =).
Practice
let name = prompt("Your name?");
Testing
Gaps
("Hello!");
Check Answer
Spots
1let name = say("Name?");
2console.log("Hi " + name);

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Giant Isopod' badge — Patient Builder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which JavaScript is the typed version of a 'say Hello' block?
A. prompt("Hello");
B. console.log("Hello"); ✓
A say block shows a message, so it becomes console.log. prompt is for asking the user a question.
2. Which block becomes prompt() when you rewrite it as JavaScript?
A. ask 'What is your name?' and wait ✓
B. say 'What is your name?'
An ask block waits for the user to type an answer, which is what prompt() does. A say block only shows a message.
3. Which line is the typed version of the block 'set score to 0'?
A. let score = 0; ✓
B. score == 0;
A set variable block creates a variable and gives it a value, so it becomes let score = 0;. A double equals compares values.
4. A script starts with 'ask What is your name?'. How do you keep the answer, like the 'answer' block does?
A. let name = prompt("What is your name?"); ✓
B. prompt("What is your name?") = name;
The answer from prompt() is stored by putting it on the right of an = sign, with the variable name on the left.
5. The block 'change score to 10' (the variable already exists) becomes which line?
A. let score = 10; written a second time
B. score = 10; ✓
Once a variable exists, changing it is a plain assignment with =. Writing let again for the same name causes an error.

Match the Pairs

console.log("Hello!"); → The typed version of a say block: it shows a message in the console.
let name = prompt("Your name?"); → The typed version of an ask block: it asks the user a question and stores the answer in a variable.
A set score to 0 block becomes a variable created with let and given a starting value. → let score = 0;
A change score by 1 block becomes an assignment that updates the existing variable, with no new let. → score = score + 1;
say("Hello!"); → say is the name of a block, not a JavaScript function. The typed version of a say block is console.log().
let age = ask("How old are you?"); → ask is a block name, not a JavaScript function. The typed version of an ask block is prompt().

Key Term

console.log, prompt, let
Blocks have typed JavaScript equivalents: a say block becomes console.log, an ask block becomes prompt, and a set variable block becomes let (or an assignment with =).

Fill in the Blanks

1. console.log("Hello!");
Hint: Type the function name that a say block becomes in JavaScript.
2. let name = prompt("What is your name?");
Hint: Type the function name that an ask block becomes, which shows a box for the user to type in.
3. let score = 0;
Hint: Type the keyword that replaces a set variable block when you create a new variable.
4. let score = 0; score = 5;
Hint: Type the symbol that assigns a new value to the existing variable, like a change variable block.
5. let name = prompt("Name?"); console.log(name);
Hint: Type the variable that holds the answer from the ask block so the say block can display it.

Spot the Error

Question 1
A let name = say("Name?");
B console.log("Hi " + name);
C console.log("Welcome!");
Line A — say is a block name, not a JavaScript function. An ask block becomes prompt, so the line should be let name = prompt("Name?");
Question 2
A set score = 0;
B score = score + 5;
C console.log(score);
Line A — set is the word on the block, not JavaScript. A set variable block becomes let, so the line should be let score = 0;
Question 3
A let player = "Sam";
B console.log("Hi, " + "player");
C console.log("Let's play!");
Line B — Quotes around player make it plain text, so the program prints the word player. Without quotes it uses the variable: console.log("Hi, " + player);
Question 4
A let lives = 3;
B let lives = lives - 1;
C console.log(lives);
Line B — A change variable block is an assignment without let. Using let again redeclares lives and causes an error. It should be lives = lives - 1;
Question 5
A let food = prompt("Food?");
B let fan = "I like " + food;
C console.log(Fan);
Line C — JavaScript is case sensitive. The variable is called fan, not Fan, so Fan is not defined. It should be console.log(fan);

Student with a class code? Join your class →