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