Camel casing

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

Camel casing

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which variable name uses camelCase?
A studentScore
B StudentScore
2. Which name is NOT camelCase?
A studentScore
B student_score
3. Which is the correct camelCase version of 'total game points'?
A totalGamePoints
B totalgamepoints
4. A class is named using PascalCase. Which name fits?
A BankAccount
B bankAccount
5. Which variable name follows camelCase rules?
A first name
B firstName

Match the Pairs

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

Left columnRight column
1studentScore AA camelCase variable name: first word lowercase, later word capitalised, no spaces
2class BankAccount: BThe first word is capitalised. In camelCase a variable should start lowercase: studentScore.
3A camelCase name for a variable holding a player's total points CA PascalCase class name: every word starts with a capital letter, including the first
4A PascalCase name for a class that models a library book Dclass LibraryBook:
5StudentScore = 85 EThe name has a space in it. Camel casing joins words with no spaces: studentScore.
6student score = 85 FtotalPoints = 0

Definitions

camelCase

Fill in the Blanks

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

1.
let studentScore = 85; console.log(____________);
2.
class StudentRecord {} let record = new _____________();
3.
___ highScore = 90; console.log(highScore);
4.
let mathsMark = 70; let englishMark = 80; let totalMarks = mathsMark _ englishMark;
5.
let firstName = "Ava"; let lastName = "Nguyen"; let fullName = firstName + " " + ________;

Spot the Error

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

Question 1
A let studentScore = 85;
B let StudentScore = 85;
C console.log(studentScore);
Question 2
A let firstName = 'Ava';
B let lastname = 'Nguyen';
C let lastname = 'Nguyen';
Question 3
A class studentRecord {
B constructor(name) {
C this.name = name;
D }
E }
Question 4
A let maxSpeed = 120;
B let currentSpeed = 80;
C let speedLimit = 100;
D let FUELLEVEL = 40;
Question 5
A class GameScore {
B constructor() {
C this.highScore = 0;
D this.PlayerName = 'Ava';
E }
F }

Answer Key

Camel casing
Section A: Quick Questions
Q1
A — studentScore
Q2
B — student_score
Q3
A — totalGamePoints
Q4
A — BankAccount
Q5
B — firstName
Section B: Match the Pairs
Q1
studentScore → A camelCase variable name: first word lowercase, later word capitalised, no spaces
Q2
class BankAccount: → A PascalCase class name: every word starts with a capital letter, including the first
Q3
A camelCase name for a variable holding a player's total points → totalPoints = 0
Q4
A PascalCase name for a class that models a library book → class LibraryBook:
Q5
StudentScore = 85 → The first word is capitalised. In camelCase a variable should start lowercase: studentScore.
Q6
student score = 85 → The name has a space in it. Camel casing joins words with no spaces: studentScore.
Section C: Definitions
Q1
camelCase — A naming style with no spaces: the first word is lowercase and each later word starts with a capital letter, like studentScore. PascalCase also capitalises the first word.
Section D: Fill in the Blanks
Q1
let studentScore = 85; console.log(studentScore);
Q2
class StudentRecord {} let record = new StudentRecord();
Q3
let highScore = 90; console.log(highScore);
Q4
let mathsMark = 70; let englishMark = 80; let totalMarks = mathsMark + englishMark;
Q5
let firstName = "Ava"; let lastName = "Nguyen"; let fullName = firstName + " " + lastName;
Section E: Spot the Error
Q1
B — A camelCase variable name must start with a lowercase letter. StudentScore is PascalCase, which is for class names. It should be studentScore.
Q2
C — In camelCase every word after the first starts with a capital letter. lastname should be lastName so the two words are easy to see.
Q3
A — Class names use PascalCase, so the first word is capitalised too. It should be StudentRecord, not studentRecord.
Q4
D — All capitals with no word breaks is not camelCase. The first word is lowercase and the second word starts with a capital, so it should be fuelLevel.
Q5
D — Properties inside a class use camelCase, which starts with a lowercase letter. PlayerName should be playerName.