2016-07-31 131 views
-3
`var y = 0 ; 
var x = 0; 
function atm(num1, num2){ 
console.log((num1 - num2)); 
return num1 - num2 ; 
} 
var items =[1,2,3,4,5,6,7,8,9,10]; 
function vm(y, x){ 
if(atm(y , items[x]) < 0 ){ 
    result = "U Do not have enough money to pay"; 
} 
else if (atm(y , items[x]) === 0 );{ 
    result = "Ur money just matches the required paying fee"; 
} 
if (atm(y , items[x]) > 0 );{ 
    result="U will reserve atm(y, items[x]) as a remainder"; 
} 
} 

vm(2, 3);` 

**的錯誤是,它給了我三個答案爲u可以看到: \\ -2JS,功能無法正常工作

「U沒有足夠的錢支付」

「烏爾錢只是匹配所需支付費用」

-2

「U將大氣壓預留(Y,項[X]),爲剩餘部分」 \\

\\ 也是第三結果「結果=」 U將大氣壓預留(Y,項[X]),爲剩餘部分」,‘不會顯示剩餘

’Y進入的錢ü保持量「

‘X去從陣列的項目數’

虛擬機是自動售貨機和它應該做的是顯示1回答這些了

1ü沒有足夠的錢支付

2 - 烏爾錢只是相匹配的要求交費

3-是他有更多的錢,他會保留「Y - 項目[X]」作爲餘

請當你長了我的錯誤寫我的錯誤和完整的代碼,有時它變得對我很難,即時通訊仍然是新的...

回答

0

我認爲這是正確的。

var y = 0; 
var x = 0; 
var items = [1,2,3,4,5,6,7,8,9,10]; 

function atm(num1, num2){ 
    return num1 - num2; 
} 


function vm(y, x) { 
    if(atm(y, items[x]) < 0 ) { 
     result = "You Do not have enough money to pay"; 
    } 
    else if (atm(y, items[x]) === 0 ) { 
     result = "Ur money just matches the required paying fee"; 
    } 
    else { 
     result = "U will reserve " + atm(y, items[x]) +" as a remainder"; 
    } 
    return result; 
} 

vm(2, 3) 
// "You Do not have enough money to pay" 
+0

非常感謝你救了我我的朋友<3 –

+0

不客氣! –