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