as variable return within a function

Asked

Viewed 22 times

-1

Function getPeson () { const name1 = 'Vagner'; const Nome2 = 'Jessica';

Return name1, Nome2; }

console.log(getPeson());

  • return only returns a value, what is after the comma will not be returned. You can resolve this with array return [nome1, nome2];

1 answer

-2

You could concatenate if the case of being two string would be like this:

return nome1 + " " + nome2;

Or if you are Javascript ES6 you can also use Template strings

 return `${nome1} ${nome2}`; 

Browser other questions tagged

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