← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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