Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
I am trying to use arguments of one function to another as a prarmeter ,using .bind

Hello there i am here trying to use the arguments of one function to parameters of another function.What i am doing here is?I am passing a score for both a and b that results to win or loose with the score i give as a argument,now i want to use that arguments to print out total score for me ,using .bind method.

var club = {
     score : function(a,b){
       
        if (a>b){
            return ('win');
        }
        else if (a<b){
            return ('lose');
        }
    }
}
var germann = function(a,b,c){
    console.log('yourmatch is: '+this.score(a,b));
    };
var germannteam = germann.bind(club);

germannteam(4,2);

So now what can i do to get print out as total of (4,2) = 6

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can add a method to club which do the calculation for this object and return the total

var club = {
  score: function(a, b) {

    if (a > b) {
      return ('win');
    } else if (a < b) {
      return ('lose');
    } else {
      return 'equality';
    }
  },
  total: function(a, b) {
    return (a > b) ? a + b : (a < b) ? a - b : 0;
  }
}
var germann = function(a, b, c) {
  console.log('yourmatch is: ' + this.score(a, b));
  console.log('your score is: ' + this.total(a, b));
};
var germannteam = germann.bind(club);

germannteam(2, 4);
germannteam(4, 2);
germannteam(4, 4);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!