← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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