← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 68
  2. let
  3. 56
  4. 67
  5. Hello, Zoya!
  6. 54
  7. 74
  8. actions and changes
  9. 1
  10. 29
  11. alert()
  12. <script>
  13. Hi, Riya!
  14. 14
  15. 51
  16. 21
  17. Hi, Kabir!
  18. 24
  19. in the console
  20. 32
  21. Hello, Riya!
  22. for
  23. 12
  24. 55
  25. let
  26. 36
  27. Hi, Arjun!
  28. 40
  29. console.log()
  30. 9
  31. 35
  32. 20
  33. 77
  34. Hi, Zoya!
  35. 74
  36. 30
  37. 25
  38. 64
  39. Welcome, Meera!
  40. Welcome, Kabir!

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