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