Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Computer object

  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Computer object

    Hey guys,

    I need to create a constructor for a computer object. This object must have three properties: speed, and mem_live mem_dead. Then I need to create a new object using this constructor and then have its properties displayed on the screen.

    Look at what I'm up to so far:

    function Computer(speed, mem_live, mem_dead)

    {
    this.speed = speed;
    this.mem_live = mem_live;
    this.mem_dead = mem_dead;
    }

    var computer1 = new Computer("4.0ghz", true, false);

    document.write(computer1.speed + " " + computer1.mem_live + " " + computer1.mem_dead);
    What am I doing wrong? It always just shows : 4.0ghz, true, false

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    did you have a question? The code looks to be correctly creating the object you desire.

  • #3
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,474
    Thanks
    13
    Thanked 361 Times in 357 Posts
    document.write() may have wiped your page.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

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