Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library

Comment by theendisney

5 months ago

Or....

  [100,500,25,10,5,1].map(coin=>{
     n = change / coin | 0
     change %= coin;
     return n 
    })

Coding on a Phone is hell

1 comment

theendisney

Reply

6510  5 months ago

    change = 12345;
    console.log(
     [100,500,25,10,5,1].map(
       coin=>[change/coin|0,change%=coin][0]
     )
    )

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities