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