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