Generating Norwegian social security numbers
Here are some general critique on the code. I'm not that familar with the specifics of javascript so I'll leave that to people who knows this better.



Validate input

When creating the object you should validate the brithday making sure it's correct. This can be done by adding a check_birthday function like e.g.

function check_birthday(day, month, year){

   // Check if month is in [1,12]
   if(month &lt; 1 || month &gt; 12) return false;

   // Check if day is valid given the month (i.e. &lt; 31, 30 (29 if leap year), 31, ...

   // Check that year is valid (get_range assumes [1900,2039])
   if(year &lt; 1900 || year &gt; 2039) return false;

   return true;
}


See this page for how the day-check can be implemented (taking leaps-years into account). Another, option is to take the input of the function to be a birthday string instead.



Functions should do what the name says it does

The addZero function (as it's used) looks useless / does not really do what it says it does. For example for dd you send in a string ddmmyyyy, extract the [0,2] part of the string giving us dd, parse that as an int, add a zero if the number is less than 10 and then return it as a string. This should be equivalent of just extracting the dd part (given that the string is a valid birthday-string) thus the only things this function really does is to extract the [min,max] part of the string and does not add any zeros.

I would do the splitting of birthday into dd, mm and yyyy outside of addZero, i.e. in the initialization.

dd = birthday.slice(0, 2);


If you need an addZero function I would make this more generic (which allows it to be used for other stuff if needed) and make sure it does exactly what the name suggest: it should take in a string/number and output a string of a given size with leading zero(s) added. Here is an example of how one can do this:

function addLeadingZeros(number, length){
   var paddednumber = '' + number;

   // Here we just return number / show error message that length
   // of number is larger than the required length
   if(number.length &gt; length) return paddednumber;

   // Pad number with zeros
   while (paddednumber.length &lt; length) {
     paddednumber = '0' + paddednumber;
   }      
   return paddednumber;
}




Other things to consider

As pointed out by Fiksdal, the third control digit i3 gives the sex of the person. If you are interested in separating between males and females when making the allowed numbers then the sex should be part of the class which can be set by changing personnr(number) to personnr(number, sex) adding sex to the individ struct and in make you need to add a check for this if(individ.i3 % 2 == individ.sex) result.push(personnr); (here for simplicity assuming sex is stored as 0 for women and 1 for men).

Right now you store the day, month and year as a string. This might be good for the intended use, but I would also consider making these into integers as this just sounds more natural to me. If you also need them as a string then this can easily be done with a addZero function.