admin管理员组

文章数量:1291097

I normally have understood this stuff well as I am taking web programming for a non-major class and guess I am just a little confused on what I'm being asked to do.

I am told to "Write a function named "MULTIPLY" that accepts 2 parameters. the function will be declared this way:

function MULTIPLY(parameter1, parameter2){
    //The parameter names can be whatever you want 
    //Your code goes here

};

I have wrote this as my code :

function MULTIPLY (price, shipping) {
    return price*shipping;

    enter code here

    product=number1*number2;

    //return the result

    return total;

I normally have understood this stuff well as I am taking web programming for a non-major class and guess I am just a little confused on what I'm being asked to do.

I am told to "Write a function named "MULTIPLY" that accepts 2 parameters. the function will be declared this way:

function MULTIPLY(parameter1, parameter2){
    //The parameter names can be whatever you want 
    //Your code goes here

};

I have wrote this as my code :

function MULTIPLY (price, shipping) {
    return price*shipping;

    enter code here

    product=number1*number2;

    //return the result

    return total;
Share Improve this question edited Dec 21, 2014 at 19:43 Deduplicator 45.7k7 gold badges72 silver badges123 bronze badges asked Oct 21, 2014 at 21:04 terryterry 211 gold badge1 silver badge2 bronze badges 1
  • 1 Your code is missing the } at the end. You also left in StackOverflow's enter code here. Please show what you actually wrote. – Barmar Commented Oct 21, 2014 at 21:07
Add a ment  | 

2 Answers 2

Reset to default 2
<script>
    function multiplyNumbers(x,y){
        return x*y;
    }
    var z= multiplyNumbers(4,5); // Function is called, return value will end up in z

</script>
<button onclick="document.getElementById('multiplication').innerHTML=z;">Multiply numbers</button>
<p id="multiplication"></p>

You have a few problems. Here is how it should look

function MULTIPLY(price, shipping) {
    //Return the sum
    return price*shipping;
}

//Call MULTIPLY to multiply the two numbers
var product=MULTIPLY(number1, number2);

本文标签: functionJavascript Multiplying 2 numbers and return numberStack Overflow