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