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