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