← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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