JavaScript Worksheet: Basics
Code tip (Line by line): let x = 5; makes a variable x holding 5; x = x + 2; changes it to 7. console.log(…) writes in the console; alert(…) shows a pop-up box. Text in quotes + anything = joined text: "5" + 3 → "53".
NameDateTime takenScore ___ / 40
-
1.⚡ What does this code show?
let name = "Arjun";
console.log("Hello, " + name + "!"); (a) name (b) Arjun (c) Hello, name! (d) Hello, Arjun! -
2.⚡ What number does this code print?
let runs = 23;
runs = runs + 6;
runs = runs - 21;
console.log(runs); - 3.⚡ What does JavaScript add to a web page? (a) actions and changes (b) only colours (c) the page title (d) the domain name
-
4.⚡ What does this code show?
let name = "Meera";
console.log("Welcome, " + name + "!"); (a) name (b) Welcome, name! (c) Meera (d) Welcome, Meera! - 5.⚡ A JavaScript file usually ends with which extension? (a) .js (b) .html (c) .css (d) .jpg
- 6.⚡ Which JavaScript word shows a pop-up box? (a) for (b) alert() (c) if (d) let
-
7.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 4;
console.log(x + y); (a) 9 (b) Error (c) 54 -
8.⚡ What number does this code print?
let coins = 28;
coins = coins + 18;
coins = coins - 3;
console.log(coins); - 9.⚡ Which JavaScript word writes in the console? (a) console.log() (b) let (c) alert() (d) for
- 10.⚡ Which JavaScript word runs code when true? (a) alert() (b) if (c) console.log() (d) let
-
11.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 2;
console.log(x + y); (a) 8 (b) Error (c) 62 - 12.⚡ Which JavaScript word makes a new variable? (a) for (b) if (c) let (d) console.log()
-
13.⚡ What does this code show?
let name = "Arjun";
alert("Welcome, " + name + "!"); (a) name (b) Welcome, Arjun! (c) Arjun (d) Welcome, name! -
14.⚡ What number does this code print?
let a = 5;
let b = 7;
console.log(a * b); - 15.⚡ Which JavaScript word repeats code? (a) for (b) console.log() (c) if (d) alert()
-
16.⚡ What number does this code print?
let apples = 14;
apples = apples + 7;
apples = apples - 15;
console.log(apples); -
17.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 1;
console.log(x + y); (a) 7 (b) 61 (c) Error - 18.⚡ Which word makes a new variable? (a) put (b) make (c) give (d) let
-
19.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Hello, name! (b) Hello, Meera! (c) name (d) Meera -
20.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 9;
console.log(x + y); (a) 17 (b) 89 (c) Error - 21.⚡ What does alert() show? (a) a picture (b) a new tab (c) a table (d) a pop-up box
- 22.⚡ Where does console.log() show its output? (a) in the console (b) on the printer (c) in the address bar (d) on the title bar
-
23.⚡ What number does this code print?
let a = 23;
let b = 20;
console.log(a + b); -
24.⚡ What number does this code print?
let a = 11;
let b = 6;
console.log(a - b); -
25.⚡ What number does this code print?
let apples = 15;
apples = apples + 2;
apples = apples - 7;
console.log(apples); -
26.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 3;
console.log(x + y); (a) 4 (b) 13 (c) Error -
27.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 6;
console.log(x + y); (a) Error (b) 36 (c) 9 -
28.⚡ What number does this code print?
let apples = 20;
apples = apples + 8;
apples = apples - 28;
console.log(apples); -
29.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 6;
console.log(x + y); (a) Error (b) 10 (c) 46 -
30.⚡ What number does this code print?
let books = 23;
books = books + 5;
books = books - 7;
console.log(books); -
31.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 2;
console.log(x + y); (a) 3 (b) 12 (c) Error -
32.⚡ What number does this code print?
let marks = 28;
marks = marks + 9;
marks = marks - 12;
console.log(marks); -
33.⚡ What number does this code print?
let marks = 22;
marks = marks + 17;
marks = marks - 18;
console.log(marks); -
34.⚡ What number does this code print?
let a = 10;
let b = 5;
console.log(a * b); -
35.⚡ What does this code show?
let name = "Riya";
alert("Hello, " + name + "!"); (a) name (b) Riya (c) Hello, Riya! (d) Hello, name! -
36.⚡ What does this code show?
let name = "Kabir";
console.log("Hello, " + name + "!"); (a) Hello, name! (b) Kabir (c) name (d) Hello, Kabir! -
37.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 2;
console.log(x + y); (a) 92 (b) 11 (c) Error -
38.⚡ What number does this code print?
let score = 21;
score = score + 17;
score = score - 23;
console.log(score); -
39.⚡ What number does this code print?
let coins = 11;
coins = coins + 4;
coins = coins - 5;
console.log(coins); -
40.⚡ What number does this code print?
let coins = 6;
coins = coins + 2;
coins = coins - 7;
console.log(coins);
Answer key
- Hello, Arjun!
- 8
- actions and changes
- Welcome, Meera!
- .js
- alert()
- 54
- 43
- console.log()
- if
- 62
- let
- Welcome, Arjun!
- 35
- for
- 6
- 61
- let
- Hello, Meera!
- 89
- a pop-up box
- in the console
- 43
- 5
- 10
- 13
- 36
- 0
- 46
- 21
- 12
- 25
- 21
- 50
- Hello, Riya!
- Hello, Kabir!
- 92
- 15
- 10
- 1
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids