← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. console.log()
  2. 48
  3. let
  4. 15
  5. 9
  6. 100
  7. 12
  8. actions and changes
  9. Hello, Aman!
  10. 47
  11. 7
  12. for
  13. let
  14. 16
  15. Well done, Arjun!
  16. 55
  17. a pop-up box
  18. 45
  19. alert()
  20. Welcome, Arjun!
  21. if
  22. 80
  23. 1
  24. 42
  25. <script>
  26. 84
  27. 58
  28. 85
  29. Well done, Kabir!
  30. 55
  31. 28
  32. 30
  33. 120
  34. 13
  35. Hi, Arjun!
  36. 29
  37. in the console
  38. 7
  39. Hi, Meera!
  40. 12

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