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