← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Hi, Meera!
  2. Welcome, Kabir!
  3. let
  4. let
  5. 80
  6. 10
  7. Welcome, Zoya!
  8. actions and changes
  9. 36
  10. for
  11. alert()
  12. Hi, Kabir!
  13. 85
  14. 86
  15. <script>
  16. a pop-up box
  17. 87
  18. console.log()
  19. Hello, Meera!
  20. 66
  21. 1
  22. 83
  23. .js
  24. Hello, Zoya!
  25. 0
  26. Hi, Riya!
  27. 50
  28. 70
  29. Hi, Riya!
  30. 33
  31. if
  32. 18
  33. 82
  34. 11
  35. 16
  36. in the console
  37. Hello, Zoya!
  38. 77
  39. 67
  40. Hello, Riya!

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