Jump to content
Sign in to follow this  
tiscavalcanti

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

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

Share this post


Link to post
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!

Share this post


Link to post
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
Sign in to follow this  

×