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