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