Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte authored Feb 2, 2024
1 parent 6b2d156 commit b63af10
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions tracks/typescript/exercises/etl/etl/mentoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Associate lowercase letters with their corresponding point values, transitioning

## Reasonable Solution

The code snippet provided in TypeScript represents a function named transform.
This function takes in an object oldData, which has keys representing point values (as strings) and values as arrays of strings (letters associated with those point values).
The code snippet provided in TypeScript represents a function named `transform`.
This function takes in an object `oldData`, which has keys representing point values (as strings) and values as arrays of strings (letters associated with those point values).

The function iterates through the oldData object, assigning each letter (converted to lowercase) to its corresponding score in the newData object.
The function iterates through the `oldData` object, assigning each letter (converted to lowercase) to its corresponding score in the `newData` object.
The return value of the function is an object where keys are lowercase letters and values are the associated point values (as numbers).

```typescript
Expand All @@ -30,36 +30,6 @@ export function transform(oldData: { [key: string]: string[] }): { [key: string]
}
```

Certainly! Here's a mentoring file for the ETL (Extract, Transform, Load) problem based on the structure of the previous mentoring file for the leap year problem:

```markdown
# Mentoring

## ETL

### Problem Overview

The ETL problem involves transforming data from an old format to a new format. In this case, the task is to restructure grouped letters by point values into individual mappings. The old format consists of point-value groups, while the new format should be letter-score pairs.

### Reasonable Solution

The provided TypeScript code represents a function named `transform`. This function takes in an object `oldData`, where keys represent point values (as strings) and values are arrays of strings (letters associated with those point values).

The function iterates through the `oldData` object, assigning each letter (converted to lowercase) to its corresponding score in the `newData` object. The return value of the function is an object where keys are lowercase letters, and values are the associated point values (as numbers).

```typescript
export function transform(oldData: { [key: string]: string[] }): { [key: string]: number } {
const newData: { [key: string]: number } = {};

for (const [score, letters] of Object.entries(oldData)) {
letters.forEach((letter: string) => {
newData[letter.toLowerCase()] = Number(score);
});
}

return newData;
}
```

### Common Suggestions:

Expand All @@ -84,4 +54,3 @@ export function transform(oldData: { [key: string]: string[] }): { [key: string]
- **Functional Approach:**
- Introduce a more functional approach using methods like `map` and `reduce` for constructing the new data object, making the code more concise.
This mentoring file aims to guide students through understanding the ETL problem, providing a reasonable solution, and offering suggestions for improvement and further exploration.

0 comments on commit b63af10

Please sign in to comment.