← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. let
  2. 58
  3. 37
  4. .js
  5. 66
  6. 22
  7. 19
  8. a pop-up box
  9. let
  10. <script>
  11. 4
  12. for
  13. Welcome, Aman!
  14. if
  15. 7
  16. in the console
  17. Hi, Meera!
  18. 74
  19. 17
  20. Hello, Meera!
  21. 57
  22. 50
  23. 26
  24. alert()
  25. 3
  26. 2
  27. 65
  28. 11
  29. 33
  30. 2
  31. 11
  32. 14
  33. console.log()
  34. Hi, Zoya!
  35. 23
  36. 9
  37. 92
  38. 80
  39. Hello, Arjun!
  40. 4

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