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