Question

Given the array below, provide the JS code to loop through the array and print each...

Given the array below, provide the JS code to loop through the array and print each item to the console prepended by "Harry Potter and the "

var books = [
  "Philosopher's Stone (1997)",
  "Chamber of Secrets (1998)",
  "Prisoner of Azkaban (1999)",
  "Goblet of Fire (2000)",
  "Order of the Phoenix (2003)",
  "Half-Blood Prince (2005)",
  "Deathly Hallows (2007)"
]

The console output should be:

Harry Potter and the Philosopher's Stone (1997)
Harry Potter and the Chamber of Secrets (1998)
Harry Potter and the Prisoner of Azkaban (1999)
Harry Potter and the Goblet of Fire (2000)
Harry Potter and the Order of the Phoenix (2003)
Harry Potter and the Half-Blood Prince (2005)
Harry Potter and the Deathly Hallows (2007)

Homework Answers

Answer #1
var books = [
    "Philosopher's Stone (1997)",
    "Chamber of Secrets (1998)",
    "Prisoner of Azkaban (1999)",
    "Goblet of Fire (2000)",
    "Order of the Phoenix (2003)",
    "Half-Blood Prince (2005)",
    "Deathly Hallows (2007)"
]

for (var i = 0; i < books.length; i++) {
    console.log("Harry Potter and the " + books[i]);
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT