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