← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. 72
  2. console.log()
  3. 25
  4. 39
  5. alert()
  6. 0
  7. in the console
  8. 43
  9. .js
  10. 24
  11. 93
  12. actions and changes
  13. 25
  14. let
  15. let
  16. if
  17. 16
  18. 29
  19. Hi, Zoya!
  20. Hi, Zoya!
  21. 81
  22. Hi, Arjun!
  23. 17
  24. Hi, Aman!
  25. 29
  26. 86
  27. 84
  28. 15
  29. 61
  30. 20
  31. Hi, Kabir!
  32. 73
  33. Hello, Riya!
  34. 10
  35. 45
  36. a pop-up box
  37. 72
  38. 10
  39. 29
  40. 12

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