← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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