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