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