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