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