← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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