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