← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. console.log()
  2. for
  3. in the console
  4. 16
  5. let
  6. 36
  7. 27
  8. Hi, Meera!
  9. 7
  10. 12
  11. Hello, Meera!
  12. <script>
  13. 13
  14. 63
  15. actions and changes
  16. alert()
  17. 25
  18. 43
  19. 5
  20. 55
  21. if
  22. 6
  23. 21
  24. 30
  25. let
  26. 26
  27. Hi, Zoya!
  28. 7
  29. 84
  30. 47
  31. Welcome, Arjun!
  32. 3
  33. 0
  34. 5
  35. 13
  36. 48
  37. 13
  38. 20
  39. 19
  40. 5

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