Typing code exactly: case, spelling and paired symbols

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Typing code exactly: case, spelling and paired symbols

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line will run correctly in JavaScript?
A Console.Log("Hi");
B console.log("Hi");
2. True or false: JavaScript treats let score = 5; and Let score = 5; as the same thing.
A False
B True
3. Which line has matching quotes?
A console.log("Hello);
B console.log("Hello");
4. Which line has its round brackets matched correctly?
A console.log("Go");
B console.log("Go";
5. Which function declaration has its curly braces matched?
A function hi() { console.log("Hi"); }
B function hi() { console.log("Hi");

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1console.log("Hi"); Aconsole.log("Done");
2{ console.log("Go"); } BThe capital letters in Console and Log are wrong. JavaScript is case-sensitive, so it must be console.log.
3JavaScript is case-sensitive, so the word console must be all lowercase. CCorrect: console.log is all lowercase, and the opening quote and bracket each have a matching closing one.
4Every opening round bracket ( must be closed with a matching ). Dconsole.log("Hello");
5Console.Log("Hi"); EEvery opening curly brace { is matched by a closing brace }, and the round brackets and quotes inside are paired too.
6console.log("Hi); FThe opening quote has no matching closing quote after Hi, so the string is never finished.

Definitions

console.log("Hi");

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
_______.log("Hello");
2.
console.___("Ready");
3.
__ (score > 5) { console.log("Win"); }
4.
let ____ = "Mia"; console.log(name);
5.
________ sayHi() { console.log("Hi"); }

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A let name = "Mia";
B let age = 13;
C console.log(name);
D console.log("Age: + age);
Question 2
A Let score = 10;
B score = score + 5;
C console.log(score);
Question 3
A function greet() {
B Console.log("Hello!");
C }
D greet();
Question 4
A for (let i = 0; i < 3; i++ {
B console.log(i);
C }
Question 5
A let total = 0;
B whlie (total < 3) {
C total++;
D }
E console.log(total);

Answer Key

Typing code exactly: case, spelling and paired symbols
Section A: Quick Questions
Q1
B — console.log("Hi");
Q2
A — False
Q3
B — console.log("Hello");
Q4
A — console.log("Go");
Q5
A — function hi() { console.log("Hi"); }
Section B: Match the Pairs
Q1
console.log("Hi"); → Correct: console.log is all lowercase, and the opening quote and bracket each have a matching closing one.
Q2
{ console.log("Go"); } → Every opening curly brace { is matched by a closing brace }, and the round brackets and quotes inside are paired too.
Q3
JavaScript is case-sensitive, so the word console must be all lowercase. → console.log("Hello");
Q4
Every opening round bracket ( must be closed with a matching ). → console.log("Done");
Q5
Console.Log("Hi"); → The capital letters in Console and Log are wrong. JavaScript is case-sensitive, so it must be console.log.
Q6
console.log("Hi); → The opening quote has no matching closing quote after Hi, so the string is never finished.
Section C: Definitions
Q1
console.log("Hi"); — JavaScript is case-sensitive, so console.log must be typed exactly. Every opening quote, bracket or brace needs a matching closing one, like the quotes and ( ) here.
Section D: Fill in the Blanks
Q1
console.log("Hello");
Q2
console.log("Ready");
Q3
if (score > 5) { console.log("Win"); }
Q4
let name = "Mia"; console.log(name);
Q5
function sayHi() { console.log("Hi"); }
Section E: Spot the Error
Q1
D — The string "Age: " is missing its closing quote, so the quote pairs are mismatched. It should be console.log("Age: " + age);
Q2
A — JavaScript is case-sensitive, so the keyword must be lowercase. Let is not the same as let. It should be let score = 10;
Q3
B — console must start with a lowercase c, and log must be lowercase too. Console.log is not the same as console.log. It should be console.log("Hello!");
Q4
A — The opening bracket ( after for has no matching closing ). It should be for (let i = 0; i < 3; i++) {
Q5
B — The keyword while is misspelt as whlie. JavaScript only understands keywords that are spelt exactly right. It should be while (total < 3) {