← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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