← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 47
  2. in the console
  3. 18
  4. 78
  5. actions and changes
  6. 42
  7. if
  8. <script>
  9. 10
  10. 77
  11. let
  12. alert()
  13. 15
  14. 36
  15. 7
  16. 68
  17. Hello, Kabir!
  18. console.log()
  19. 88
  20. Hello, Zoya!
  21. a pop-up box
  22. 2
  23. for
  24. 25
  25. 18
  26. Hello, Zoya!
  27. 1
  28. Welcome, Zoya!
  29. 6
  30. Hello, Riya!
  31. 33
  32. 97
  33. 67
  34. 27
  35. 7
  36. 0
  37. 13
  38. 30
  39. 83
  40. Welcome, Aman!

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