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