← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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