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