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