← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. Hello, Zoya!
  2. 46
  3. alert()
  4. Hi, Zoya!
  5. Well done, Zoya!
  6. 5
  7. .js
  8. Welcome, Meera!
  9. if
  10. 26
  11. for
  12. 77
  13. Well done, Aman!
  14. 36
  15. 60
  16. a pop-up box
  17. let
  18. actions and changes
  19. in the console
  20. 89
  21. let
  22. 45
  23. 14
  24. 81
  25. 56
  26. 74
  27. 11
  28. 9
  29. 17
  30. 3
  31. 33
  32. 13
  33. 49
  34. 73
  35. 94
  36. 45
  37. 92
  38. console.log()
  39. 6
  40. 61

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