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