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.
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)
}
Great, this works. Thanks!