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