← JavaScript basics lesson New set →

JavaScript Worksheet: Basics

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

Answer key

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

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