I know that you have your answer already but I wanted to elaborate a bit with some comments on your code which I hope will help you write a bit cleaner and better code (+ some new stuff from ECMAScript6).
There two major things I would recommend - always indent your code and do add some comments in it.
So here is the code with some comments:
// always use better names of your functions (names that would be like a hint what is the purpose of that function)
function ra (length) {
// all the variables that won't change during your function should be declared as constansts
const consonants = "123456789".split('');
const vowels = '123456789'.split('');
const consonantLength = consonants.length;
const vowelsLength = vowels.length;
let rand = function(limit){
return Math.floor(Math.random()*limit);
}
// no need to declar i here when you can do so in the for loop
//-- var i = '';
// not sure why would you use this radix (the second argument of parseInt)
length = parseInt(length,10);
// there is no need to perform the split() on a separate row as this can be done with the initial declaration of your
//-- consonants = consonants.split('');
//-- vowels = vowels.split('');
let word = '';
let loopLength = length/2; // check this for more explanations https://stackoverflow.com/questions/8452317/do-loops-check-the-array-length-every-time-when-comparing-i-against-array-length
for (let i = 0; i < loopLength; i++) {
// in your code you where using consonants.length which will be executed each time so instead of this I will use the constant consonantLength that I have declared above
let randConsonant = consonants[rand(consonantLength)];
let randVowel = vowels[rand(vowelsLength)];
// not sure what are you doing here, so can't comment much. It is a very good practice to leave some comments on places where the main logic of your code is happening
word += (i === 0) ? randConsonant.toLowerCase() : randConsonant;
word += i*2 < length-1 ? randVowel : '';
}
return word;
}
// the jQuery event 'click' is a bit old and will get some day deprecated, instead I would suggest to use 'on'
$("#click").on('click',function(){
$("#test").text('');
//-- var pass1 = ra; // there is no need of this row. you can just call the function ra down below in the loop
for(var p = 0; p < 5; p++){
$("#test").append(ra(3)+'\n');
}
});
$("#combine").on('click',function(){
// let's get the value from the textarea, and as it will be a string we need to split it by rows
// btw: I believe there is a better regex that will exclude the last \n
let userpass = document.getElementById('test').value.split(/\n/g);
// and we remove the last element from the array that will be an empty one
userpass.pop();
// we loop through all the elements from the array
for (let row of userpass) {
// we do check if there is value in row as the last element will be an empty string
$("#test").append(row+":"+row+'\n');
}
});
And a JSFiddle