2014-10-21 66 views
-3

我通常已经理解了这个东西,因为我正在为一个非主要的课程进行网络编程,并且猜测我对于被要求做的事情只是有点困惑。 。Javascript-乘以2个号码和返回号码

我告知“编写命​​名函数‘接受2个参数正片叠底’的功能将这样声明:

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

}; 

我已经写了这是我的代码:

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

    enter code here 

    product=number1*number2; 

    //return the result 

    return total; 
+1

您的代码缺少'}'结尾。您还在StackOverflow上的左'在这里输入代码'。请显示你实际写的内容。 – Barmar 2014-10-21 21:07:38

回答

0

你有一些问题。这是它应该如何看

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

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

谢谢DrRoach。我也很困惑的是//一些代码部分。这与“返回”功能有关吗? – terry 2014-10-21 21:10:30

+0

完全没有,这就是在你真正使用'MULTIPLY'函数之前你想要做的任何javascript代码。 '//'表示它是一个注释,并且实际上从来没有被代码运行过。 – DrRoach 2014-10-21 21:12:02

+0

我很欣赏你的反馈,所以它不会“//返回结果”? – terry 2014-10-21 21:16:03