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