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