Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:10:14+00:00 2026-06-14T19:10:14+00:00

I am trying to make method chaining work in conjunction with my constructors, but

  • 0

I am trying to make method chaining work in conjunction with my constructors, but I am not exactly sure how to go about it. Here is my code thus far:

function Points(one, two, three) {
this.one = one;
this.two = two;
this.three = three;
}

Points.prototype = {

add: function() {
    return this.result = this.one + this.two + this.three;
},
multiply: function() {
    return this.result * 30;
}

}

var some = new Points(1, 1, 1);
console.log(some.add().multiply());

I am trying to call the multiply method on the return value of the add method. I know there is something obvious that I am not doing, but I am just not sure what it is.

Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:10:15+00:00Added an answer on June 14, 2026 at 7:10 pm

    You should not return the result of the expression. Instead return this.

    Points.prototype = {
    
        add: function() {
            this.result = this.one + this.two + this.three;
            return this;
        },
        multiply: function() {
            this.result = this.result * 30;
            return this;
        }
    
    }
    

    And then use it like this: console.log(some.add().multiply().result);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

1st Question: I'm trying to make the create method work, but it appears that
I'm trying to make a method that will tell me weather or not it
I'm trying to make a method with optional parameter SpriteFont = myFont work. Because
Im trying to make an async method that returns a value. everything work when
I'm trying to make a search method using a binary tree(no, it's not a
I am trying to make a generic Duplicate linq extension method. But I cannot
I am trying to make an add method for a linked list, but for
I'm trying to make tiny helper method for simplify routine operations But on the
I'm trying to make a method of compressing file using Ionic.Zip.dll of DotNetZip. Code
I am trying to make my WCF service method to return JSON-object, but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.