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