First, let's recap on how the average_score function was written:
function average_score(n = 10) story_ids = fetch_top_stories() println(now(), " Found ", length(story_ids), " stories") top_stories = [fetch_story(id) for id in story_ids[1:min(n,end)]] println(now(), " Fetched ", n, " story details") avg_top_scores = mean(s.score for s in top_stories) println(now(), " Average score = ", avg_top_scores) return avg_top_scoresend
Although the code looks quite decent and simple to understand, let me point out some potential issues:
- The top stories are retrieved via array comprehension syntax. The logic is a little busy and we won't be able to test this part of the code independently ...