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