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