← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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