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