← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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