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