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