Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6248619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:05:32+00:00 2026-05-24T13:05:32+00:00

I just have a small question that I would like some clarification about, if

  • 0

I just have a small question that I would like some clarification about, if I have created a function that is set up to accept 2 parameters and then perform some calculation but then I realise that the function I have created could also be used in another part of my code but will need to accept an additional parameter, how can use the function but pass in an additional parameter?

Regards
Kyle

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:05:33+00:00Added an answer on May 24, 2026 at 1:05 pm

    You basically create a function function with any number of parameters and call them by passing any number of parameters.

    For example:

        function Test(a,b,c)
        {
        }
    
    
     //callling Test
      Test(1)
      Test(1,2)  // now inside Function Test c will be undefined
      Test(1,2,3)
      Test(1,2,3,4) // note here i have passed an additonal paramter that will be totally ignored
    

    You can create a calculator like below

    function Calculate(num1, num2, operation)
    {
    operation= operation || 'sum'; //sum is the default operator
    if(operation == 'sum')
    {
    return num1 + num2 ;
    }
    if(operation == 'multiply')
    {
    return num1 * num2 ;
    }
    if(operation == 'subtract')
    {
    return num1 - num2 ;
    }
    if(operation == 'divide')
    {
    return num1 / num2 ;
    }
    }
    
    
    Calculate(1, 2)  //returns 3  -- defaut operator is picked
    Calculate(1, 2, 'sum')  //returns 3
    Calculate(1, 2, 'multiply')  //returns 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small flash file that just loads and shows one image scaled
Ok guys just a small game: I have some specifications for a project. At
I'm a LOB .NET applications developer that would like to do some www consumer
It seems that a lot of small business people have a need for some
I've recently decided that I just have to finally learn C/C++, and there is
I am reading a text file with this format: grrr,some text,45.4321,54.22134 I just have
I have just inherited a server application, however it seems that the only copy
I have just set up cruise control.net on our build server, and I am
I have a straightforward question. I am doing a web application that uses MySQL,
I have a question about Javascript widgets. The widget I am working on simply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.