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