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