jeudi 6 octobre 2016

Cant figure out how to get this name generator working

For school I'm doing an assignment where we need to make a random name generator for male and female names and we have to put numbers in front of it but i can't figure out how to do that. The generator itself is working but its the number part i can't figure out. The numbers need to go from 1 to a maximum of 100.

var number = ["1", "2", "3", "4", "5"];
var randomnumber = Math.floor(Math.random() * number.length);
var counter = number[randomnumber];

document.write("Female Names");
document.write("<br>");
function femaleName (){
// My variables.
// Klinkers.
var klinker = ["o", "a", "i", "e", "u"];
var randomnumberk = Math.floor(Math.random() * klinker.length);
var randomklinker = klinker[randomnumberk];
var randomnumberk1 = Math.floor(Math.random() * klinker.length);
var randomklinker1 = klinker[randomnumberk1];
var randomnumberk2 = Math.floor(Math.random() * klinker.length);
var randomklinker2 = klinker[randomnumberk2];
var randomnumberk3 = Math.floor(Math.random() * klinker.length);
var randomklinker3 = klinker[randomnumberk3];
var randomnumberk4 = Math.floor(Math.random() * klinker.length);
var randomklinker4 = klinker[randomnumberk4];
// Medeklinkers.
var medeklinker = ["b", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "z",]
var randomnumbermk = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker = medeklinker[randomnumbermk];
var randomnumbermk1 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker1 = medeklinker[randomnumbermk1];
var randomnumbermk2 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker2 = medeklinker[randomnumbermk2];
var randomnumbermk3 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker3 = medeklinker[randomnumbermk3];
var randomnumbermk4 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker4 = medeklinker[randomnumbermk4];
document.write(number, randomklinker, randommedeklinker, randomklinker1, randommedeklinker1, randomklinker2);
document.write("<br>");
}

for ( var i = 0; i < 6; i++) {
femaleName();
}

document.write("<br>");
document.write("<br>");
document.write("<br>");
document.write("Male names");
document.write("<br>");

function maleName (){
// My variables.
// Klinkers.
var klinker = ["o", "a", "i", "e", "u"];
var randomnumberk = Math.floor(Math.random() * klinker.length);
var randomklinker = klinker[randomnumberk];
var randomnumberk1 = Math.floor(Math.random() * klinker.length);
var randomklinker1 = klinker[randomnumberk1];
var randomklinker2 = klinker[randomnumberk2];
var randomnumberk3 = Math.floor(Math.random() * klinker.length);
var randomklinker3 = klinker[randomnumberk3];
var randomnumberk4 = Math.floor(Math.random() * klinker.length);
var randomklinker4 = klinker[randomnumberk4];
// Medeklinkers.
var medeklinker = ["b", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "z",]
var randomnumbermk = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker = medeklinker[randomnumbermk];
var randomnumbermk1 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker1 = medeklinker[randomnumbermk1];
var randomnumbermk2 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker2 = medeklinker[randomnumbermk2];
var randomnumbermk3 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker3 = medeklinker[randomnumbermk3];
var randomnumbermk4 = Math.floor(Math.random() * medeklinker.length);
var randommedeklinker4 = medeklinker[randomnumbermk4];
document.write(randommedeklinker, randomklinker, randommedeklinker1, randomklinker1, randommedeklinker2);
document.write("<br>");
}

for ( var i = 0; i < 6; i++) {
  maleName();
}

I hope that someone here can help me with this problem.




Aucun commentaire:

Enregistrer un commentaire