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