2014-10-21 67 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