Online Coding Lessons JavaScript Coding for Kids 3 — Questions and Answers
Question 1: Which loop is best for repeating an action a set number of times, like 10 times?
- for loop (Correct answer)
- if statement
- function
- comment
Correct answer: for loop
A for loop repeats code a chosen number of times.
Question 2: What does the length property tell you about an array?
- How many items it has (Correct answer)
- Its color
- Its name
- Its speed
Correct answer: How many items it has
The length property gives the number of items in an array.
Question 3: Which code adds the item "cat" to the end of an array called pets?
- pets.push("cat") (Correct answer)
- pets.add("cat")
- pets.cat()
- push.pets("cat")
Correct answer: pets.push("cat")
The push() method adds a new item to the end of an array.
Question 4: What is the first index number of any array in JavaScript?
- 0 (Correct answer)
- 1
- -1
- 10
Correct answer: 0
Arrays start counting positions at 0, not 1.
Question 5: What does an if statement let your program do?
- Make a decision (Correct answer)
- Change the font
- Save a file
- Refresh the page
Correct answer: Make a decision
An if statement runs code only when a condition is true.
Question 6: Which symbol means "is equal to" when comparing values in JavaScript?
- === (Correct answer)
- =
- =>
- !=
Correct answer: ===
Three equal signs check if two values are truly equal.
Question 7: What does a while loop do?
- Repeats code while a condition stays true (Correct answer)
- Stops the program
- Draws a picture
- Adds two numbers once
Correct answer: Repeats code while a condition stays true
A while loop keeps running as long as its condition is true.
Which loop is best for repeating an action a set number of times, like 10 times?