← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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