← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 57
  2. .js
  3. let
  4. 29
  5. console.log()
  6. <script>
  7. alert()
  8. actions and changes
  9. Well done, Aman!
  10. Hi, Riya!
  11. 25
  12. Hello, Arjun!
  13. 16
  14. 69
  15. Welcome, Aman!
  16. in the console
  17. 19
  18. 24
  19. 92
  20. 29
  21. 7
  22. 32
  23. 120
  24. for
  25. 49
  26. 53
  27. 42
  28. 3
  29. 2
  30. 32
  31. if
  32. 13
  33. 39
  34. let
  35. 18
  36. 14
  37. 32
  38. Hello, Meera!
  39. 52
  40. 14

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