← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 14
  2. alert()
  3. 1
  4. let
  5. 54
  6. 28
  7. actions and changes
  8. console.log()
  9. 6
  10. 13
  11. .js
  12. 3
  13. 72
  14. 44
  15. <script>
  16. 11
  17. if
  18. in the console
  19. 12
  20. Hello, Zoya!
  21. 12
  22. Well done, Meera!
  23. 4
  24. 1
  25. 96
  26. 36
  27. 2
  28. 55
  29. 49
  30. 83
  31. Hello, Aman!
  32. 58
  33. Welcome, Meera!
  34. Well done, Kabir!
  35. 8
  36. let
  37. 0
  38. Hi, Aman!
  39. 2
  40. Hi, Arjun!

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