← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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