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