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