Skip to content

Instantly share code, notes, and snippets.

@antonybudianto
Last active February 8, 2019 02:43
Show Gist options
  • Select an option

  • Save antonybudianto/9c6704370117e8151f35785910569841 to your computer and use it in GitHub Desktop.

Select an option

Save antonybudianto/9c6704370117e8151f35785910569841 to your computer and use it in GitHub Desktop.

Revisions

  1. antonybudianto revised this gist Feb 8, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion currency simple
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    function cur (n) {
    return (n).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')
    let minus = n < 0
    n = minus ? Math.abs(n) : n
    return (minus ? '-' : '') + (n).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')
    }
  2. antonybudianto revised this gist Feb 7, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion currency simple
    Original file line number Diff line number Diff line change
    @@ -1 +1,3 @@
    (5200000).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')
    function cur (n) {
    return (n).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')
    }
  3. antonybudianto created this gist Feb 6, 2019.
    1 change: 1 addition & 0 deletions currency simple
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    (5200000).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')