2017-07-24 75 views
-1

所以我用戶輸入的值使用提示和輸入的值應該通過功能,讓輸出輸入值轉換成javascript函數

function isEven(a) 
{ 


if (a%2==0) { 
    console.log(a+"is true"); 
} 
else 
{ 
    console.log(a+"is false"); 
} 

return a; 
} 

isEven(5); 

回答

0

這裏要的是你的更新代碼:

var number = prompt("Please enter your number: ") 
 

 
console.log(number + ' is ' + isEven(number)); 
 

 
function isEven(a) { 
 
    return a % 2; // 0 means Even and 1 means ODD 
 
}

0
isEven(parseInt(prompt("Please enter your number : ")))