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