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