Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda