← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Hi, Zoya!
  2. in the console
  3. alert()
  4. actions and changes
  5. for
  6. 71
  7. 91
  8. 90
  9. console.log()
  10. if
  11. 17
  12. 21
  13. Welcome, Meera!
  14. 60
  15. .js
  16. 20
  17. Welcome, Kabir!
  18. 59
  19. Hello, Zoya!
  20. a pop-up box
  21. 16
  22. Welcome, Aman!
  23. 56
  24. 15
  25. 5
  26. 26
  27. 44
  28. 68
  29. 22
  30. let
  31. 7
  32. 16
  33. 3
  34. Hi, Aman!
  35. 26
  36. 63
  37. 53
  38. 72
  39. 74
  40. 60

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