Javascript function - help

Asked

Viewed 2,281 times

-1

someone helps me in this activity, I do not understand and does not get in the head, I have not seen a good explanation.

Now we ask you to declare a function called tripleDaSoma() that takes two parameters. Then you have to add both and return three times the result value of the sum of the two parameters. To do this, you already count (even if you don’t see it declared) with the triple function, which takes a parameter and returns its value multiplied by three.

I tried to do so.

function triploDaSoma(num1, num2){
        function triplo(num1, num2){
            var resultado1 = somar(3, 2) * 3;
        return resultado1;
        }
        var resultado = somar(4, 5) * 3;
        return resultado;
}

but there’s a mistake saying it’s missing: Mistakes:

You must use the triple() function within tripleDaSoma The execution of the triple functionDaSoma(3,2) must return the value 15 triple functionDaSoma(4,5) must return the value 27

Honestly if I don’t learn Function I give up javascript.

  • What is your doubt?

  • Could you show what you tried? What language are you using? This guide can help you improve this question. https://pt.meta.stackoverflow.com/questions/5483/manual-de-como-nÃo-fazer-perguntas

  • I didn’t understand how to do a bad function and I have to create another one inside, I swear I’ve seen so many videos and I’ve read so much about it but it hasn’t entered my head...

  • try to do like this: Function tripleDaSoma(num1, num2){ Function triple(num1, num2){ var resultado1 = sum(3, 2) * 3; Return results1; } var result = add(4, 5) * 3; turn result; }

  • You always say you’re wrong. You must use the triple() function within tripleDaSoma The execution of the triple functionDaSoma(3,2) must return the value 15 The execution of the triple functionDaSoma(4,5) must return the value 27

  • Edit your question with this code and explain why you tried it in the question, because the question is not very clear :/

  • Reading the error, it seems that you use an exercise platform and she wants you to use the function triplo to make the multiplication

  • yes, it’s from Santander Coder, a scholarship for training devs. And I’m in the first week of elimination...

Show 3 more comments

1 answer

5


From what I understand of the statement, it is not for you to create the function triplo, is for you to consider that it already exists and use it.

Assuming this is the triple function:

function triplo(valor) {
    return valor * 3;
}

Your job would be to invoke it within the function triploDaSoma:

function triploDaSoma(a, b) {
    var soma = a + b;
    var resultado = triplo(soma);
    return resultado;
}
  • Man what vision, I copied this way and I pasted it worked... guy that level that can be like this? congratulations on your knowledge and thank you...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.