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