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) alert() (b) let (c) for (d) console.log()
- 2.⚡ Which JavaScript word makes a new variable? (a) console.log() (b) if (c) let (d) for
-
3.⚡ What does this code show?
let name = "Kabir";
alert("Hi, " + name + "!"); (a) Hi, name! (b) name (c) Hi, Kabir! (d) Kabir - 4.⚡ Which tag holds JavaScript in a page? (a) <code> (b) <js> (c) <script> (d) <style>
- 5.⚡ Which JavaScript word repeats code? (a) for (b) console.log() (c) let (d) if
-
6.⚡ What number does this code print?
let a = 37;
let b = 20;
console.log(a - b); -
7.⚡ What number does this code print?
let a = 6;
let b = 1;
console.log(a + b); -
8.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 1;
console.log(x + y); (a) 2 (b) 11 (c) Error -
9.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 6;
console.log(x + y); (a) 86 (b) Error (c) 14 -
10.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 7;
console.log(x + y); (a) Error (b) 12 (c) 57 -
11.⚡ What does this code show?
let name = "Zoya";
alert("Welcome, " + name + "!"); (a) Welcome, Zoya! (b) Zoya (c) name (d) Welcome, name! -
12.⚡ What does this code show?
let name = "Riya";
alert("Hello, " + name + "!"); (a) name (b) Hello, Riya! (c) Hello, name! (d) Riya -
13.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 8;
console.log(x + y); (a) Error (b) 18 (c) 9 -
14.⚡ What number does this code print?
let apples = 12;
apples = apples + 4;
apples = apples - 15;
console.log(apples); - 15.⚡ A JavaScript file usually ends with which extension? (a) .jpg (b) .js (c) .css (d) .html
-
16.⚡ What does this code show?
let name = "Arjun";
console.log("Well done, " + name + "!"); (a) Well done, Arjun! (b) name (c) Arjun (d) Well done, name! -
17.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 4;
console.log(x + y); (a) 74 (b) 11 (c) Error - 18.⚡ Which JavaScript word shows a pop-up box? (a) alert() (b) if (c) for (d) let
-
19.⚡ What number does this code print?
let coins = 28;
coins = coins + 8;
coins = coins - 24;
console.log(coins); -
20.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 3;
console.log(x + y); (a) 13 (b) 4 (c) Error - 21.⚡ Which JavaScript word runs code when true? (a) let (b) console.log() (c) alert() (d) if
-
22.⚡ What does this code show?
let name = "Zoya";
alert("Hi, " + name + "!"); (a) name (b) Hi, name! (c) Hi, Zoya! (d) Zoya -
23.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 9;
console.log(x + y); (a) Error (b) 19 (c) 10 -
24.⚡ What number does this code print?
let a = 10;
let b = 5;
console.log(a * b); - 25.⚡ What does alert() show? (a) a new tab (b) a table (c) a picture (d) a pop-up box
-
26.⚡ What does this code show?
let name = "Meera";
alert("Hi, " + name + "!"); (a) Hi, Meera! (b) Meera (c) name (d) Hi, name! -
27.⚡ What number does this code print?
let marks = 25;
marks = marks + 2;
marks = marks - 5;
console.log(marks); -
28.⚡ What number does this code print?
let a = 30;
let b = 24;
console.log(a + b); -
29.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 9;
console.log(x + y); (a) 69 (b) Error (c) 15 -
30.⚡ What number does this code print?
let coins = 20;
coins = coins + 14;
coins = coins - 1;
console.log(coins); -
31.⚡ What number does this code print?
let a = 35;
let b = 33;
console.log(a - b); -
32.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 4;
console.log(x + y); (a) 54 (b) 9 (c) Error -
33.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Hello, name! (b) Meera (c) Hello, Meera! (d) name -
34.⚡ What number does this code print?
let apples = 9;
apples = apples + 16;
apples = apples - 24;
console.log(apples); -
35.⚡ What number does this code print?
let a = 24;
let b = 11;
console.log(a - b); -
36.⚡ What number does this code print?
let coins = 17;
coins = coins + 18;
coins = coins - 3;
console.log(coins); -
37.⚡ What number does this code print?
let a = 59;
let b = 5;
console.log(a + b); -
38.⚡ What does this code show?
let name = "Aman";
console.log("Hello, " + name + "!"); (a) Aman (b) Hello, name! (c) Hello, Aman! (d) name -
39.⚡ What number does this code print?
let a = 32;
let b = 7;
console.log(a + b); -
40.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 2;
console.log(x + y); (a) Error (b) 32 (c) 5
Answer key
- console.log()
- let
- Hi, Kabir!
- <script>
- for
- 17
- 7
- 11
- 86
- 57
- Welcome, Zoya!
- Hello, Riya!
- 18
- 1
- .js
- Well done, Arjun!
- 74
- alert()
- 12
- 13
- if
- Hi, Zoya!
- 19
- 50
- a pop-up box
- Hi, Meera!
- 22
- 54
- 69
- 33
- 2
- 54
- Hello, Meera!
- 1
- 13
- 32
- 64
- Hello, Aman!
- 39
- 32
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids