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