← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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