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