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