Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKarol Pisula
2,578 PointsForeach problem
I made an array called PhoneBook and how to i use foreach in it foreach("what do i write here" in PhoneBook){} how do i use foreach like what do i write here to loop it
Joseph Brown
11,601 PointsJoseph Brown
11,601 PointsThe syntax for a foreach loop is the following.
so in your example, lets say your phonebook array contained integers representing the digits of a phonenumber. ex: {5551055, 1112222, 4443333}
This code would print all numbers in the phonebook array to the console.