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