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