I have been doing some basic js but I am not sure if I am using semicolons correctly. Here is my code:
//creates a variable that will start the game
var start = confirm("Are you sure want to participate in plonker base alpha?");
//starts and loops the game
if(start){
//asks for another person's name
var person1 = prompt("Please name one of your best friends.")
}
//creates a randomizer function
var random = function (subject){
return subject[Math.floor(subject.length * Math.random())]
}
while(start){
//creates array 'person'
var person = ["You are ","Your mum is ","Your dad is ", "The world is ",(person1 + " is ")];
var personGenerator = random(person);
//creates an array 'offence'
var offence = ["an idiot!",
"a complete pysco!!!",
"a smelly, worthless peice of junk!",
"a whale re-incarnated that looks like a squirrel!",
"a dumb pile of dirt that has the misfortune of seeing itself in the mirror once in a while!",
"a complete and utter plonker!",
"a dumbo!",
"a right dufus!!!",
"a pile of rabbit dung!",
"an intelligant, good looking king being... Did I mention - it's opposite day!",
"a bum-faced rat!!!",
"a fat, lazy oaf!",
"a blobfish look-alike!!!!!",
"a lump of toenail jelly!"
];
var offenceGenerator = random(offence);
//gives out the offence
alert(personGenerator + offenceGenerator);
}
{
alert("What a plonker!")
}
Please correct me in the comments if I am using them wrong.
Thanks, Reece C.