Jump to content

How to Put a function with two parameters in a Array?


tiscavalcanti

Recommended Posts

You can have your function return an array, but unless you're operating a and z together in two different ways, I don't see a reason to do it.

 

Returning both values with an array:

function val(a, z) {  return [ a/2, z+8 ];}

A better approach:

function half(x) {  return x/2;}function plus8(x) {  return x + 8;}
  • Like 1
Link to comment
Share on other sites

 

You can have your function return an array, but unless you're operating a and z together in two different ways, I don't see a reason to do it.

 

Returning both values with an array:

function val(a, z) {  return [ a/2, z+8 ];}

A better approach:

function half(x) {  return x/2;}function plus8(x) {  return x + 8;}

Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...