← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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