← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. in the console
  2. alert()
  3. 65
  4. 24
  5. 58
  6. 78
  7. 21
  8. let
  9. actions and changes
  10. 73
  11. 21
  12. for
  13. 74
  14. 33
  15. 22
  16. 67
  17. 88
  18. 49
  19. 66
  20. Well done, Aman!
  21. a pop-up box
  22. 7
  23. 24
  24. let
  25. 0
  26. 1
  27. 20
  28. if
  29. 29
  30. 29
  31. 1
  32. console.log()
  33. <script>
  34. Welcome, Zoya!
  35. 18
  36. 26
  37. Hi, Arjun!
  38. Hello, Zoya!
  39. 8
  40. 48

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