I'm attempting to combine the initial letter of both names with the randomly generated code.
var firstname = prompt("Please input your first name.");
var lastname = prompt ("Please input your last name.");
if (amountCorrect >= 4){
alert("Your store login Code is: " + str(firstname,1,1) + str(lastname,1,1) + (generateCode())); // Execute the generateCode function
}
else{
alert("You didn't pass this time. You will be redirected back to the homepage.");
window.history.go(-1); // Navigate back one step
}
}
function generateCode(){
var text = "";
var possible = "0123456789";
for( var i=0; i < 4; i++ ){
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}