SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Beginner: how come this method doesn't work? Looks fine to me.

    UPDATE: okaaay, looks like I screwed ups. I forgot the equal sign.
    fruit.goodness = function ()

    I have spent many hours trying to figure this out. I am sure all the experts on this forum can catch the problem within seconds. Any help would be greatly appreciated. Thanks.

    Isn't the output supposed to be 10? I did not use any of the properties in the fruit object, but it should still work.

    Code:
    <html>
    <body>
    
    <script type="text/javascript">
    
    var fruit = { e:1, f:4, g:6};
    
    fruit.goodness function () {
    	var x = 9
    	return x+1;
    };
    
    document.write(fruit.goodness());
    
    
    </script>
    
    </body>
    </html>

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Your missing an equal sign and using a debugger would of helped you - ie firebug for Firefox
    Code:
    fruit.goodness = function () {


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •