← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 812 · 40 questions
TalentJR

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

Answer key

  1. <script>
  2. a pop-up box
  3. let
  4. Hi, Arjun!
  5. 6
  6. actions and changes
  7. 43
  8. let
  9. Welcome, Zoya!
  10. 17
  11. 16
  12. 28
  13. .js
  14. Hi, Meera!
  15. 63
  16. for
  17. Hello, Riya!
  18. 61
  19. Hi, Aman!
  20. in the console
  21. Well done, Aman!
  22. 40
  23. console.log()
  24. if
  25. 3
  26. Hello, Zoya!
  27. 48
  28. 7
  29. Hello, Meera!
  30. 22
  31. 73
  32. 22
  33. 14
  34. 16
  35. alert()
  36. 7
  37. 6
  38. 77
  39. 72
  40. Welcome, Arjun!

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids