Skip to content

Instantly share code, notes, and snippets.

@nestedfunction
Forked from Ugrend/medicare_card.js
Created May 31, 2022 02:24

Revisions

  1. @Ugrend Ugrend created this gist May 11, 2018.
    15 changes: 15 additions & 0 deletions medicare_card.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@

    //Reference: http://www.clearwater.com.au/code/provider

    const randomMedicareNumber = ()=>{
    let sum = Math.floor(Math.random() * 5) +2;
    const weights = [1, 3, 7, 9, 1, 3, 7, 9];
    let num = [sum]
    for(let i = 0 ; i < 7 ; i++){
    let n = Math.floor(Math.random()*10)
    sum += n * weights[i+1];
    num.push(n)
    }
    num.push(sum % 10)
    return num.join('') + '1/1';
    }