← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 757 · 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) alert() (b) for (c) console.log() (d) let
  2. 2.⚡ Which word makes a new variable? (a) put (b) give (c) let (d) make
  3. 3.⚡ What does this code print? (Look at the quotes!)
    let x = "2";
    let y = 6;
    console.log(x + y);
    (a) Error (b) 8 (c) 26
  4. 4.⚡ Which JavaScript word writes in the console? (a) console.log() (b) for (c) alert() (d) let
  5. 5.⚡ What does this code show?
    let name = "Kabir";
    console.log("Welcome, " + name + "!");
    (a) Welcome, Kabir! (b) name (c) Welcome, name! (d) Kabir
  6. 6.⚡ What does JavaScript add to a web page? (a) the domain name (b) the page title (c) only colours (d) actions and changes
  7. 7.⚡ Which JavaScript word makes a new variable? (a) if (b) console.log() (c) let (d) alert()
  8. 8.⚡ What number does this code print?
    let books = 23;
    books = books + 7;
    books = books - 8;
    console.log(books);
  9. 9.⚡ What does this code show?
    let name = "Riya";
    alert("Hi, " + name + "!");
    (a) Riya (b) Hi, Riya! (c) Hi, name! (d) name
  10. 10.⚡ What number does this code print?
    let books = 5;
    books = books + 4;
    books = books - 3;
    console.log(books);
  11. 11.⚡ What number does this code print?
    let marks = 15;
    marks = marks + 4;
    marks = marks - 11;
    console.log(marks);
  12. 12.⚡ What number does this code print?
    let a = 33;
    let b = 10;
    console.log(a + b);
  13. 13.⚡ What does this code print? (Look at the quotes!)
    let x = "8";
    let y = 1;
    console.log(x + y);
    (a) 81 (b) 9 (c) Error
  14. 14.⚡ What number does this code print?
    let coins = 7;
    coins = coins + 16;
    coins = coins - 23;
    console.log(coins);
  15. 15.⚡ What does this code print? (Look at the quotes!)
    let x = "6";
    let y = 4;
    console.log(x + y);
    (a) Error (b) 64 (c) 10
  16. 16.⚡ What number does this code print?
    let a = 16;
    let b = 39;
    console.log(a + b);
  17. 17.⚡ What does this code show?
    let name = "Kabir";
    console.log("Well done, " + name + "!");
    (a) Well done, Kabir! (b) Well done, name! (c) Kabir (d) name
  18. 18.⚡ What does this code print? (Look at the quotes!)
    let x = "1";
    let y = 4;
    console.log(x + y);
    (a) Error (b) 5 (c) 14
  19. 19.⚡ What does this code show?
    let name = "Meera";
    alert("Welcome, " + name + "!");
    (a) Meera (b) Welcome, name! (c) Welcome, Meera! (d) name
  20. 20.⚡ What number does this code print?
    let a = 37;
    let b = 15;
    console.log(a - b);
  21. 21.⚡ What does this code show?
    let name = "Meera";
    console.log("Hi, " + name + "!");
    (a) name (b) Meera (c) Hi, Meera! (d) Hi, name!
  22. 22.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 2;
    console.log(x + y);
    (a) 72 (b) Error (c) 9
  23. 23.⚡ What number does this code print?
    let books = 25;
    books = books + 13;
    books = books - 12;
    console.log(books);
  24. 24.⚡ What number does this code print?
    let marks = 13;
    marks = marks + 2;
    marks = marks - 9;
    console.log(marks);
  25. 25.⚡ Which JavaScript word repeats code? (a) let (b) console.log() (c) alert() (d) for
  26. 26.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 5;
    console.log(x + y);
    (a) 9 (b) 45 (c) Error
  27. 27.⚡ What does this code print? (Look at the quotes!)
    let x = "7";
    let y = 8;
    console.log(x + y);
    (a) 78 (b) 15 (c) Error
  28. 28.⚡ What number does this code print?
    let a = 7;
    let b = 8;
    console.log(a * b);
  29. 29.⚡ What number does this code print?
    let a = 38;
    let b = 11;
    console.log(a + b);
  30. 30.⚡ What number does this code print?
    let a = 3;
    let b = 2;
    console.log(a * b);
  31. 31.⚡ What number does this code print?
    let a = 28;
    let b = 12;
    console.log(a - b);
  32. 32.⚡ What does this code show?
    let name = "Riya";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) Riya (c) name (d) Well done, Riya!
  33. 33.⚡ What number does this code print?
    let a = 14;
    let b = 10;
    console.log(a + b);
  34. 34.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 2;
    console.log(x + y);
    (a) 42 (b) Error (c) 6
  35. 35.⚡ What does alert() show? (a) a new tab (b) a pop-up box (c) a picture (d) a table
  36. 36.⚡ What does this code print? (Look at the quotes!)
    let x = "9";
    let y = 4;
    console.log(x + y);
    (a) 13 (b) 94 (c) Error
  37. 37.⚡ What number does this code print?
    let books = 10;
    books = books + 15;
    books = books - 14;
    console.log(books);
  38. 38.⚡ What does this code show?
    let name = "Meera";
    console.log("Welcome, " + name + "!");
    (a) name (b) Welcome, name! (c) Meera (d) Welcome, Meera!
  39. 39.⚡ What does this code print? (Look at the quotes!)
    let x = "3";
    let y = 8;
    console.log(x + y);
    (a) 38 (b) Error (c) 11
  40. 40.⚡ Which JavaScript word runs code when true? (a) for (b) console.log() (c) if (d) let

Answer key

  1. alert()
  2. let
  3. 26
  4. console.log()
  5. Welcome, Kabir!
  6. actions and changes
  7. let
  8. 22
  9. Hi, Riya!
  10. 6
  11. 8
  12. 43
  13. 81
  14. 0
  15. 64
  16. 55
  17. Well done, Kabir!
  18. 14
  19. Welcome, Meera!
  20. 22
  21. Hi, Meera!
  22. 72
  23. 26
  24. 6
  25. for
  26. 45
  27. 78
  28. 56
  29. 49
  30. 6
  31. 16
  32. Well done, Riya!
  33. 24
  34. 42
  35. a pop-up box
  36. 94
  37. 11
  38. Welcome, Meera!
  39. 38
  40. if

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