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