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