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