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