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