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