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