← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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