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