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