← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Well done, Meera!
  2. 33
  3. 3
  4. 77
  5. a pop-up box
  6. Hello, Zoya!
  7. Welcome, Kabir!
  8. for
  9. 72
  10. 17
  11. 65
  12. 17
  13. 5
  14. console.log()
  15. alert()
  16. 77
  17. 13
  18. 10
  19. 18
  20. Hello, Kabir!
  21. 1
  22. 30
  23. 1
  24. 19
  25. 34
  26. let
  27. 8
  28. 63
  29. 26
  30. 67
  31. actions and changes
  32. 18
  33. let
  34. .js
  35. 59
  36. 14
  37. <script>
  38. 27
  39. 9
  40. 14

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