← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. for
  2. Well done, Zoya!
  3. 89
  4. .js
  5. Welcome, Riya!
  6. let
  7. in the console
  8. 29
  9. 32
  10. 62
  11. 13
  12. Hello, Aman!
  13. 22
  14. 35
  15. actions and changes
  16. alert()
  17. 35
  18. 91
  19. console.log()
  20. if
  21. 8
  22. Well done, Kabir!
  23. 77
  24. 17
  25. Welcome, Zoya!
  26. 15
  27. 28
  28. 6
  29. Hi, Riya!
  30. 53
  31. Welcome, Aman!
  32. 7
  33. let
  34. 45
  35. 82
  36. 11
  37. 31
  38. 1
  39. 12
  40. 18

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