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