← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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