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