← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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