← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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