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