← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. console.log()
  2. a pop-up box
  3. 13
  4. if
  5. 12
  6. for
  7. 91
  8. actions and changes
  9. <script>
  10. Well done, Arjun!
  11. Hi, Riya!
  12. 76
  13. 90
  14. Hi, Kabir!
  15. 45
  16. let
  17. .js
  18. 4
  19. 40
  20. 47
  21. Hello, Kabir!
  22. alert()
  23. 22
  24. 23
  25. Well done, Riya!
  26. 35
  27. 99
  28. Welcome, Riya!
  29. 94
  30. let
  31. 13
  32. in the console
  33. 25
  34. 28
  35. 87
  36. 18
  37. 10
  38. 4
  39. Hello, Riya!
  40. 53

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