← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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