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