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