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