← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

  1. alert()
  2. 30
  3. 12
  4. if
  5. a pop-up box
  6. 54
  7. 41
  8. console.log()
  9. for
  10. Hi, Arjun!
  11. 20
  12. let
  13. 30
  14. 61
  15. 31
  16. Welcome, Kabir!
  17. <script>
  18. 24
  19. 28
  20. 96
  21. 60
  22. 56
  23. 98
  24. 62
  25. 24
  26. 3
  27. Welcome, Kabir!
  28. actions and changes
  29. 85
  30. 51
  31. 6
  32. 3
  33. 25
  34. Well done, Meera!
  35. 28
  36. 1
  37. 49
  38. 31
  39. in the console
  40. 40

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