← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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