← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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