← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 45
  2. <script>
  3. .js
  4. let
  5. 29
  6. actions and changes
  7. 8
  8. 13
  9. 23
  10. 9
  11. 4
  12. 1
  13. 8
  14. 66
  15. 51
  16. 50
  17. 22
  18. alert()
  19. 95
  20. 68
  21. 37
  22. 9
  23. 16
  24. for
  25. 22
  26. 7
  27. console.log()
  28. 3
  29. 81
  30. 12
  31. in the console
  32. 37
  33. Welcome, Kabir!
  34. 65
  35. 36
  36. 1
  37. a pop-up box
  38. 94
  39. if
  40. 84

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