← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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