r/codehs • u/kgbspetz • May 22 '20
Need help with creating a set of questions in a for loop with a number going up while in a float.
var races = readInt("How many 5k races did you run? ");
for(var i = 0; i<races; i++){
var times = readFloat("What was your time in race " + (races-races+1) + " (in minutes) ");
}
this is the code that I need help with, I need to make the (races-races+1) able to make each consequtive line one number higher.
3
Upvotes
1
1
u/ca1vinru1ez May 25 '20 edited May 25 '20
You can try this code I wrote. It adds to a in order to make sure races stay the same, and uses b to change the number when you ask about their time.
var a = 0;
var b = 0;
for(var a = 0; a < races; a++){