views:

60

answers:

1

can you use parameters some how to alter 'book' and 'person' in this statement : book.borrower= person; eg JSObj.borrower = "SteveJobs"; I cannot seem to find a way, Is there one?

+1  A: 

Maybe you meant to have something like this:

function changeBorrower(book, person)
{
    book.borrower = person;
}

// USAGE
changeBorrower(JSObj, "SteveJobs");
Makram Saleh
Makram, thanks for your responseIn fact I have similar code iefunction loanbook (book, lender) {book.borrower = lender;alert(book.borrower);}loanbook("JSObj", "Frank");but its not working??
Further to your response, I noticed you had no "" around JSObjI have removed mine and it works fine, why is that?Thank you so muchAlan
Because a string literal and a variable are completely different things.
David Dorward
David,thanks...what a bunny...i've just started playing with OOP. I understand now, thank you for your response