-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amethyst - AnBa - Adagram JS #144
base: main
Are you sure you want to change the base?
Conversation
// global variable | ||
const LETTER_POOL = { | ||
A: 9, | ||
B: 2, | ||
C: 2, | ||
D: 4, | ||
E: 12, | ||
F: 2, |
There was a problem hiding this comment.
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 😄
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)); | ||
} |
There was a problem hiding this comment.
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 ✅
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] | ||
]); |
There was a problem hiding this comment.
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!
wordValue += letterValue; | ||
} | ||
|
||
if (word.length >= 7 && word.length <= 10) { | ||
wordValue += 8; |
There was a problem hiding this comment.
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 👍🏾
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; |
There was a problem hiding this comment.
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
No description provided.