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