← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

HTML and CSS lesson 25: JavaScript basics · Set 511 · 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 marks = 9;
    marks = marks + 17;
    marks = marks - 19;
    console.log(marks);
  2. 2.⚡ Which JavaScript word shows a pop-up box? (a) if (b) alert() (c) let (d) for
  3. 3.⚡ What number does this code print?
    let coins = 7;
    coins = coins + 3;
    coins = coins - 6;
    console.log(coins);
  4. 4.⚡ What number does this code print?
    let apples = 10;
    apples = apples + 3;
    apples = apples - 8;
    console.log(apples);
  5. 5.⚡ What does this code print? (Look at the quotes!)
    let x = "6";
    let y = 3;
    console.log(x + y);
    (a) Error (b) 63 (c) 9
  6. 6.⚡ What does this code show?
    let name = "Arjun";
    alert("Welcome, " + name + "!");
    (a) Welcome, name! (b) Welcome, Arjun! (c) name (d) Arjun
  7. 7.⚡ What does this code show?
    let name = "Meera";
    alert("Welcome, " + name + "!");
    (a) Welcome, Meera! (b) Meera (c) Welcome, name! (d) name
  8. 8.⚡ What number does this code print?
    let a = 41;
    let b = 19;
    console.log(a + b);
  9. 9.⚡ What does alert() show? (a) a pop-up box (b) a table (c) a new tab (d) a picture
  10. 10.⚡ Which JavaScript word makes a new variable? (a) let (b) alert() (c) for (d) console.log()
  11. 11.⚡ What number does this code print?
    let a = 7;
    let b = 9;
    console.log(a * b);
  12. 12.⚡ Which JavaScript word writes in the console? (a) alert() (b) if (c) for (d) console.log()
  13. 13.⚡ What number does this code print?
    let books = 18;
    books = books + 19;
    books = books - 1;
    console.log(books);
  14. 14.⚡ What number does this code print?
    let runs = 15;
    runs = runs + 4;
    runs = runs - 6;
    console.log(runs);
  15. 15.⚡ What number does this code print?
    let a = 49;
    let b = 10;
    console.log(a - b);
  16. 16.⚡ What does this code print? (Look at the quotes!)
    let x = "5";
    let y = 8;
    console.log(x + y);
    (a) 13 (b) Error (c) 58
  17. 17.⚡ What does this code show?
    let name = "Zoya";
    console.log("Welcome, " + name + "!");
    (a) name (b) Welcome, name! (c) Zoya (d) Welcome, Zoya!
  18. 18.⚡ What number does this code print?
    let apples = 24;
    apples = apples + 9;
    apples = apples - 16;
    console.log(apples);
  19. 19.⚡ What does this code print? (Look at the quotes!)
    let x = "9";
    let y = 8;
    console.log(x + y);
    (a) Error (b) 17 (c) 98
  20. 20.⚡ What number does this code print?
    let books = 12;
    books = books + 4;
    books = books - 3;
    console.log(books);
  21. 21.⚡ What number does this code print?
    let a = 30;
    let b = 28;
    console.log(a - b);
  22. 22.⚡ What number does this code print?
    let a = 30;
    let b = 19;
    console.log(a - b);
  23. 23.⚡ What number does this code print?
    let score = 10;
    score = score + 20;
    score = score - 4;
    console.log(score);
  24. 24.⚡ What does this code show?
    let name = "Arjun";
    console.log("Hello, " + name + "!");
    (a) Hello, name! (b) Arjun (c) name (d) Hello, Arjun!
  25. 25.⚡ What number does this code print?
    let apples = 26;
    apples = apples + 9;
    apples = apples - 33;
    console.log(apples);
  26. 26.⚡ What does this code show?
    let name = "Riya";
    console.log("Well done, " + name + "!");
    (a) Well done, name! (b) name (c) Riya (d) Well done, Riya!
  27. 27.⚡ What does this code show?
    let name = "Aman";
    alert("Hi, " + name + "!");
    (a) Aman (b) Hi, Aman! (c) name (d) Hi, name!
  28. 28.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 9;
    console.log(x + y);
    (a) 49 (b) 13 (c) Error
  29. 29.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 8;
    console.log(x + y);
    (a) Error (b) 48 (c) 12
  30. 30.⚡ What number does this code print?
    let score = 27;
    score = score + 4;
    score = score - 7;
    console.log(score);
  31. 31.⚡ What does this code print? (Look at the quotes!)
    let x = "4";
    let y = 1;
    console.log(x + y);
    (a) 41 (b) 5 (c) Error
  32. 32.⚡ What number does this code print?
    let a = 40;
    let b = 15;
    console.log(a - b);
  33. 33.⚡ What number does this code print?
    let a = 44;
    let b = 6;
    console.log(a - b);
  34. 34.⚡ What number does this code print?
    let a = 19;
    let b = 24;
    console.log(a + b);
  35. 35.⚡ What number does this code print?
    let books = 19;
    books = books + 17;
    books = books - 24;
    console.log(books);
  36. 36.⚡ What does this code print? (Look at the quotes!)
    let x = "3";
    let y = 1;
    console.log(x + y);
    (a) 4 (b) 31 (c) Error
  37. 37.⚡ What does this code print? (Look at the quotes!)
    let x = "9";
    let y = 2;
    console.log(x + y);
    (a) Error (b) 92 (c) 11
  38. 38.⚡ Which word makes a new variable? (a) let (b) make (c) give (d) put
  39. 39.⚡ What does this code show?
    let name = "Aman";
    console.log("Hello, " + name + "!");
    (a) Aman (b) Hello, Aman! (c) name (d) Hello, name!
  40. 40.⚡ Where does console.log() show its output? (a) in the address bar (b) on the printer (c) on the title bar (d) in the console

Answer key

  1. 7
  2. alert()
  3. 4
  4. 5
  5. 63
  6. Welcome, Arjun!
  7. Welcome, Meera!
  8. 60
  9. a pop-up box
  10. let
  11. 63
  12. console.log()
  13. 36
  14. 13
  15. 39
  16. 58
  17. Welcome, Zoya!
  18. 17
  19. 98
  20. 13
  21. 2
  22. 11
  23. 26
  24. Hello, Arjun!
  25. 2
  26. Well done, Riya!
  27. Hi, Aman!
  28. 49
  29. 48
  30. 24
  31. 41
  32. 25
  33. 38
  34. 43
  35. 12
  36. 31
  37. 92
  38. let
  39. Hello, Aman!
  40. in the console

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