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