Day in the Race Loop Help

Hey all, I have trouble building out the loop for “find_place”. Specifically, I don’t know how to make the “place” increase to the correct number in the “else” part

Thanks.

Hi,

Try with this:

find_place <- function(runner) {
place <- 1
for (name in race_results) {
if (race_results[place] == runner)
return(place)
else {
place <- place + 1
}
}
return(place)
}

1 Like

Great, this works. Thanks!