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