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