← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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