← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. console.log()
  2. let
  3. .js
  4. 36
  5. 48
  6. let
  7. Welcome, Riya!
  8. 10
  9. <script>
  10. for
  11. 11
  12. 26
  13. 9
  14. 4
  15. 45
  16. Welcome, Arjun!
  17. Hello, Aman!
  18. 89
  19. if
  20. 21
  21. a pop-up box
  22. 7
  23. alert()
  24. 70
  25. 24
  26. 47
  27. 17
  28. 60
  29. Hi, Riya!
  30. in the console
  31. 35
  32. 18
  33. 4
  34. 51
  35. 11
  36. 4
  37. 79
  38. Hello, Zoya!
  39. Hello, Riya!
  40. 18

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