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