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