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