← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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