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