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