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