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