← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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