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