← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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