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