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