Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 3511f66

Browse files
author
Dedekind561
committed
improve clarity for mode problem
1 parent df08541 commit 3511f66

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

week-2/stretch/mode.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// You are given an implementation of calculateMode
2-
// calculateMode does 2 things:
3-
// 1. One part of the code tracks the frequency of each value
4-
// 2. The other part finds the value with the highest frequency
2+
3+
// calculateMode's implementation can be broken down into two stages:
4+
5+
// Stage 1. One part of the code tracks the frequency of each value
6+
// Stage 2. The other part finds the value with the highest frequency
57

68
// refactor calculateMode by splitting up the code
7-
// into smaller functions with different roles
9+
// into smaller functions using the stages above
810

911
function calculateMode(list) {
1012
// track frequency of each value

0 commit comments

Comments
 (0)