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