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