Hi everyone,
can anyone help me with my code, i am having a hard time trying to make the first letter of a string a capital, and the rest lowercase... here is my code

<script type="text/javascript">
var input= prompt("Please input a word.");
var thelength= input.length;
var test="";
for(var i=0; i<thelength; i++){
var num1 = Math.floor(Math.random() * input.length);
test += input.substring(num1,num1+1);
}
// here is where i am having my problem, i want my output to be first character UpperCase and the rest of the output LowerCase. I only thought it has something to to with the substr method but i dunno thx!
InitChar=test.substr(0,1).toUpperCase();


</script>