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