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