← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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