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