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