← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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