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