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 number does this code print?
let a = 24;
let b = 34;
console.log(a + b); - 2.⚡ Which JavaScript word writes in the console? (a) alert() (b) if (c) console.log() (d) for
- 3.⚡ Which JavaScript word runs code when true? (a) alert() (b) if (c) let (d) console.log()
- 4.⚡ A JavaScript file usually ends with which extension? (a) .jpg (b) .css (c) .js (d) .html
-
5.⚡ What number does this code print?
let apples = 7;
apples = apples + 16;
apples = apples - 14;
console.log(apples); -
6.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 8;
console.log(x + y); (a) Error (b) 14 (c) 68 -
7.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 9;
console.log(x + y); (a) Error (b) 12 (c) 39 -
8.⚡ What number does this code print?
let a = 40;
let b = 13;
console.log(a - b); - 9.⚡ Which word makes a new variable? (a) make (b) put (c) give (d) let
-
10.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 2;
console.log(x + y); (a) 32 (b) Error (c) 5 -
11.⚡ What does this code show?
let name = "Riya";
console.log("Hi, " + name + "!"); (a) name (b) Hi, name! (c) Riya (d) Hi, Riya! -
12.⚡ What does this code show?
let name = "Meera";
alert("Hello, " + name + "!"); (a) Hello, Meera! (b) Meera (c) name (d) Hello, name! -
13.⚡ What number does this code print?
let runs = 23;
runs = runs + 5;
runs = runs - 12;
console.log(runs); -
14.⚡ What number does this code print?
let a = 7;
let b = 9;
console.log(a + b); - 15.⚡ What does JavaScript add to a web page? (a) the domain name (b) actions and changes (c) the page title (d) only colours
-
16.⚡ What number does this code print?
let books = 14;
books = books + 5;
books = books - 6;
console.log(books); -
17.⚡ What number does this code print?
let runs = 18;
runs = runs + 5;
runs = runs - 17;
console.log(runs); -
18.⚡ What number does this code print?
let marks = 7;
marks = marks + 4;
marks = marks - 6;
console.log(marks); -
19.⚡ What number does this code print?
let a = 5;
let b = 6;
console.log(a * b); - 20.⚡ Which JavaScript word repeats code? (a) for (b) let (c) if (d) console.log()
-
21.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Hello, Meera! (b) Meera (c) name (d) Hello, name! -
22.⚡ What number does this code print?
let a = 35;
let b = 5;
console.log(a - b); -
23.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 3;
console.log(x + y); (a) 43 (b) Error (c) 7 -
24.⚡ What number does this code print?
let score = 20;
score = score + 9;
score = score - 5;
console.log(score); - 25.⚡ Which JavaScript word shows a pop-up box? (a) let (b) alert() (c) for (d) console.log()
-
26.⚡ What number does this code print?
let a = 44;
let b = 1;
console.log(a + b); -
27.⚡ What number does this code print?
let a = 25;
let b = 1;
console.log(a + b); -
28.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 5;
console.log(x + y); (a) Error (b) 10 (c) 55 -
29.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 2;
console.log(x + y); (a) 6 (b) 42 (c) Error - 30.⚡ What does alert() show? (a) a table (b) a picture (c) a pop-up box (d) a new tab
-
31.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 8;
console.log(x + y); (a) 13 (b) 58 (c) Error -
32.⚡ What number does this code print?
let a = 8;
let b = 36;
console.log(a + b); - 33.⚡ Which JavaScript word makes a new variable? (a) console.log() (b) let (c) if (d) for
-
34.⚡ What number does this code print?
let a = 2;
let b = 7;
console.log(a * b); -
35.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 8;
console.log(x + y); (a) Error (b) 15 (c) 78 -
36.⚡ What number does this code print?
let a = 2;
let b = 8;
console.log(a * b); -
37.⚡ What does this code show?
let name = "Riya";
alert("Hi, " + name + "!"); (a) Riya (b) name (c) Hi, Riya! (d) Hi, name! -
38.⚡ What number does this code print?
let books = 8;
books = books + 17;
books = books - 1;
console.log(books); -
39.⚡ What number does this code print?
let a = 37;
let b = 12;
console.log(a + b); -
40.⚡ What does this code show?
let name = "Kabir";
alert("Hello, " + name + "!"); (a) Hello, name! (b) Kabir (c) name (d) Hello, Kabir!
Answer key
- 58
- console.log()
- if
- .js
- 9
- 68
- 39
- 27
- let
- 32
- Hi, Riya!
- Hello, Meera!
- 16
- 16
- actions and changes
- 13
- 6
- 5
- 30
- for
- Hello, Meera!
- 30
- 43
- 24
- alert()
- 45
- 26
- 55
- 42
- a pop-up box
- 58
- 44
- let
- 14
- 78
- 16
- Hi, Riya!
- 24
- 49
- Hello, Kabir!
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids