← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 32
  2. actions and changes
  3. alert()
  4. 72
  5. let
  6. 11
  7. 8
  8. 63
  9. 33
  10. 12
  11. .js
  12. 88
  13. console.log()
  14. Well done, Meera!
  15. 30
  16. 77
  17. a pop-up box
  18. 9
  19. let
  20. 30
  21. 132
  22. 96
  23. Hello, Riya!
  24. <script>
  25. 11
  26. Well done, Arjun!
  27. Hello, Arjun!
  28. 3
  29. Welcome, Arjun!
  30. 40
  31. for
  32. 88
  33. 25
  34. 13
  35. 99
  36. 75
  37. 9
  38. 73
  39. 23
  40. in the console

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