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