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