← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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