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