Skip to content

Conversation

@ngwin-ab
Copy link

@ngwin-ab ngwin-ab commented Jun 7, 2023

No description provided.

Comment on lines +1 to +8
// global variable
const LETTER_POOL = {
A: 9,
B: 2,
C: 2,
D: 4,
E: 12,
F: 2,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job creating this global variable outside of each function so each function can access it & we can also keep the program DRY 😄

Comment on lines 34 to +38
export const drawLetters = () => {
// Implement this method for wave 1
let letterList = [];
for (let [letter, freq] of Object.entries(LETTER_POOL)) {
letterList.push(...Array(freq).fill(letter));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work getting comfortable with JavaScript's syntax. It looks like you're getting use to looping over data and adding conditional logic ✅

Comment on lines +56 to +64
const valuesMap = new Map([
[['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 1],
[['D', 'G'], 2],
[['B', 'C', 'M', 'P'], 3],
[['F', 'H', 'V', 'W', 'Y'], 4],
[['K'], 5],
[['J', 'X'], 8],
[['Q', 'Z'], 10]
]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent choice with this data structure!

Comment on lines +77 to +81
wordValue += letterValue;
}

if (word.length >= 7 && word.length <= 10) {
wordValue += 8;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job translating this logic 👍🏾

Comment on lines +94 to +102
words.forEach(word => {
const currentScore = scoreWord(word);

if (currentScore > result.score) {
result.word = word;
result.score = currentScore;
} else if (currentScore === result.score) {
if (result.word.length !== 10 && (word.length === 10 || word.length < result.word.length)) {
result.word = word;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi An Ba! Great job completing JS Adagrams! Congrats on finishing your first JavaScript project 🎉 Excellent choice with this scoring approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants