In JS, I'm trying to make a random compliment generator using Arrays. The goal is that when the program is run, it takes a random part from each array and then displays the string. I'm sure i've used far too many variables here, but I am struggling.
The variables at the top of the page (whatList, descriptionList, and betterthanList) are what i've been given, and the rest is my attempt to solve it.
var whatList = ["hair", "face", "figure", "brain", "taste in music", "ability to code in Javascript"];
var descriptionList = ["pretty", "intelligent", "beautiful", "astute", "like tasting a rainbow"];
var betterthanList = ["a weekend for two in the Algarve", "a gold medal on Nooblab", "the baldness of Paul Neve", "a slap up meal in Subway in the student union"];
var random1 = Math.random()*7;
var randoma = Math.floor(random1);
var random2 = Math.random()*6;
var randomb = Math.floor(random2);
var random3 = Math.random()*5;
var randomc = Math.floor(random3);
var whatChoice1;
var whatChoice2;
var whatChoice3;
var whatChoice4;
var whatChoice5;
var whatChoice6;
var desChoice1;
var desChoice2;
var desChoice3;
var desChoice4;
var desChoice5;
var betterChoice1;
var betterChoice2;
var betterChoice3;
var betterChoice4;
if(randoma = 0)
{
whatChoice1 = whatList[0];
}
else if (randoma = 1)
{
whatChoice2 = whatList[1];
}
else if(randoma = 2)
{
whatChoice3 = whatList[2];
}
else if(randoma = 3)
{
whatChoice4 = whatList[3];
}
else if(randoma = 4)
{
whatChoice5 = whatList[4];
}
else if(randoma = 5)
{
whatChoice6 = whatList[5];
}
if (randomb = 0)
{
desChoice1 = descriptionList[0];
}
else if (randomb = 1)
{
desChoice2 = descriptionList[1];
}
else if(randomb = 2)
{
desChoice3 = descriptionList[2];
}
else if(randomb = 3)
{
desChoice4 = descriptionList[3];
}
else if(randomb = 4)
{
desChoice5 = descriptionList[4];
}
if(randomc = 0)
{
betterChoice1 = betterthanList[0];
}
else if (randomc = 1)
{
betterChoice2 = betterthanList[1];
}
else if(randomc = 2)
{
betterChoice3 = betterthanList[2];
}
else if(randomc = 3)
{
betterChoice4 = betterthanList[3];
}
console.log("Your " + whatChoice[] + " is" + desChoice[] + " and better than" + betterChoice[]);