I need help, I’ve writen an code that randomly assigns an alliance to the user, then I wanted to do a condition that runs a function if the user gets a certain alliance, this means, if you get marine in the next line it appears a role from the marines, or if you get revolucionary army it appears a role from the revolucionary army. Note: This roles would also be random as the alliance.
This is my code:
function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
function alliance(){
var alliance = ["Revolucionary Army","Marine","Pirate","Bounty Hunter","Cipher Pol","Royalist","Celestial Dragon"];
var alliance = capFirst(alliance[getRandomInt(0, alliance.length + 1)]);
document.getElementById("alliance").innerHTML = alliance;
}
/* Rank */
function rank() {
function rankrevolucionary(){
var rankrevolucionary = ["Leader","Chief of Staff","Army Commander","Officer","Member","Associate"];
var rankrevolucionary = capFirst(rankrevolucionary[getRandomInt(0, rankrevolucionary.length + 1)]);
document.getElementById("rankrevolucionary").innerHTML = rankrevolucionary;
}
function rankmarine(){
var rankmarine = ["Fleet Admiral","Admiral","Vice Admiral","Rear Admiral"];
var rankmarine = capFirst(rankmarine[getRandomInt(0, rankmarine.length + 1)]);
document.getElementById("rankmarine").innerHTML = rankmarine;
}
}