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