← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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