← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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