How can I use the for loop in the code to help choosing bestComrade?


How can I use the for loop in the code to help choosing bestComrade?

var tovarischArray = ["Lenin", "Stalin", "Khruschev", "Brezhnev", "Unnamed", "Gorbachev", "Yeltsin", "?"]

var comradePicker = Math.random();

for(i = 0.125; i <= 1; i += 0.125) {

if (pisKy <= 0.125) { bestComrade = tovarischArray[0] } else if (pisKy <= 0.250) { bestComrade = tovarischArray[1] } else if (pisKy <= 0.375) { bestComrade = tovarischArray[2] } else if (pisKy <= 0.500) { bestComrade = tovarischArray[3] } else if (pisKy <= 0.625) { bestComrade = tovarischArray[4] } else if (pisKy <= 0.750) { bestComrade = tovarischArray[5] } else if (pisKy <= 0.875) { bestComrade = tovarischArray[6] } else if (pisKy <= 1) { bestComrade = tovarischArray[7] } }

Submitted September 27, 2016 at 11:21PM by RenaissanceThought
via reddit http://ift.tt/2cIzg4U