← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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