← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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