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