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