← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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