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