/    Sign up×
Community /Pin to ProfileBookmark

Code help, database for loop :(

The code is suppose to define an array of four objects that represent an address book database. The address book object has three properties named name,address and phone. The code uses a for loop to search the databasefor the name clyde and then display clydes phone number.

Here’s what i have:
can you help?

<script type=”text/javascript”>
var addresses = new Array (3)
addresses[0] = addressEntry (“Bill”, “123 Main Street”, “321-4567”)
addresses[1] = addressEntry (“Theresa”,”456 Elm Place, “987-1234”)
addresses[2] = addressEntry (“Emily”, “65 Oriole Drive”,”487-0246″)
addresses[3] = addressEntry (“Clyde”, “1003 Court Street”,”357-9087″)
var ctr
for (ctr = 0; ctr<3; ctr++){
if (addressEntry [0] = “Clyde”) {
alert (“The number for Clyde is: “+address.phone)
}
}
</script>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoDec 02.2005 — <i>
</i>&lt;script type="text/javascript"&gt;
var addresses = new Array ();
addresses[0] = new Array("Bill", "123 Main Street", "321-4567");
addresses[1] = new Array("Theresa","456 Elm Place", "987-1234");
addresses[2] = new Array("Emily", "65 Oriole Drive","487-0246");
addresses[3] = new Array("Clyde", "1003 Court Street","357-9087");
var i;
for (i = 0; i&lt;addresses.length; i++)
{
if (addresses [i][0] = "Clyde")
{
alert ("The number for Clyde is: " + addresses[i][2]);
i = addresses.length;
}
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@gina4unccauthorDec 02.2005 — Thanks KON ?
Copy linkTweet thisAlerts:
@konithomimoDec 02.2005 — NO problem. I'm glad to have been of help.
×

Success!

Help @gina4uncc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...