← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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