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