我通常已经理解了这些东西,因为我正在为一个非主要课程进行网络编程,并且猜测我对我被要求做的事情感到有些困惑。
我被告知"写一个名为" MULTIPLY"接受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;
答案 0 :(得分:1)
<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>
答案 1 :(得分:0)
你有一些问题。这是它应该看起来的样子
function MULTIPLY(price, shipping) {
//Return the sum
return price*shipping;
}
//Call MULTIPLY to multiply the two numbers
var product=MULTIPLY(number1, number2);
答案 2 :(得分:0)
function multiply(a, b) {
let first = parseInt(prompt("Enter 1st Value"));
let second = parseInt(prompt("Enter 2nd Value"));
return first * second;
}
multiply();