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