javascript - How to generate 4 digits alphanumeric code in meteor? -


How to specify Generate alphanumeric code with 4 digits with recurrence?

You ask 4 points, but also say 'alphanumeric'. Either way:

  generated function 4DigitNonRepeatingNumericCode () {ret = ""; While (ret.length & lt; 4) {var pickanumberBetween0 and 9 = ("+++ Math.random ()). CharAt (2); if (ret.indexOf (" + + pickanumberBetween0 and 9) == -1) Rate + = Picanambar Between 0 and 9;} Return Return;}   

This is not a meteorite-specific, it can be used in any JavaScript app. For Alphanumeric we have a Will take the shortcut and Meteor.Collection.ObjectID :

  generated function of the meteor 4CharacterNonRepeatingAlphanumericCode () {ret = ""; while (ret.length> 4) { var pickACharacter = ("new meteorite" compilation. objectIDID () .hexString ()). (0); if (ret.indexOf ("+ pickacharacter) == -1) Rate + = Pakacrocessor; } Return return; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -