← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

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