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