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