← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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