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