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