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