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