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