← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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