Help to solve two Javascript questions [closed]

closed . This question needs details or to be clearer and is not currently accepting answers.

Want to improve this question? Add details and make it clearer what problem is being solved by editing this post .

Closed 1 year ago .

improve this question

Hello, I am not able to solve these two questions, Could you help me.

function dobroDoNumero (){
  var dobroA = 4+4;
  var dobroB = 7+7;
  var dobroC = 8+-8;
  var resultado = dobroA+ ', ' +dobroB+ ', ' +dobroC
  return resultado
}
function metade(){
  var num1 = 4/2;
  var num2 = 60/2;
  var num3 = 30/2;
  var resultado = num1+ ', ' +num2+ ', ' +num3;
  return resultado
  console.log(resultado)
}

Thank you :)

Author: Lilla Oliveira, 2019-07-28

1 answers

Hello.

In the first code has an error that is showing in the console: 8,14,0.

The error is on the Fourth Line: var dobroC = 8+-8;

Solution:

function dobroDoNumero(){
  var dobroA = 4*2;
  var dobroB = 7*2;
  var dobroC = 8*2;
  var resultado = dobroA+ ', ' +dobroB+ ', ' +dobroC;
  return resultado;
}
console.log(dobroDoNumero());
// 8, 14, 16

In the second code, the error is in the console.log(resultado) call after the return resultado; call.

Solution:

function metade(){
  var num1 = 4/2;
  var num2 = 60/2;
  var num3 = 30/2;
  var resultado = num1+ ', ' +num2+ ', ' +num3;
  console.log(resultado);
// 2, 30, 15
  return resultado;
}
metade()

I hope I helped.

 1
Author: Maury Developer, 2019-07-28 16:57:23