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