Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// 20/20:找錢
function change(cash) {
  if(cash === 0 || cash === 1 || cash === 'number') return null;
    
      let ten = Math.floor(cash / 10)
      
      let five = Math.floor((cash % 10) / 5)
      
      let two = Math.floor(((cash % 10) % 5) / 2)
  
  return {
    ten:ten,
    five:five,
    two:two,
  }
 
}
try {
  console.log(change(1)); // null
  console.log(change(42).ten);
  console.log(change(42).five);
  console.log(change(42).two);
  console.log(change(90071992547409).ten);
  
}
catch(error) {
  console.error(error);
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
tsuifeipro
0viewers