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