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