Skip to content

Conversation

@ryjpink
Copy link

@ryjpink ryjpink commented Jan 23, 2023

No description provided.

export const scoreWord = (word) => {
// Implement this method for wave 3
};
export class Adagrams{

Choose a reason for hiding this comment

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

nice use of OOP!

this.letterPool = [];
for (let alphabet in letterMap){
let times = letterMap[alphabet];
for (let i=0; i<times; ++i)

Choose a reason for hiding this comment

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

ahh, this is how I think about setting up the pool, with the appropriate stats for picking a random letter with a given frequency distribution for each letter, too!

const letterBank = [];
let length = this.letterPool.length;

while (letterBank.length < 10){

Choose a reason for hiding this comment

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

This loops makes sense, and I don't think you really have to worry about it here, but when I see
while loops like this, I think about adding some other kind of guard condition- like limiting the
number of attempts, for example-- to catch a possible infinite loop if there weren't enough letters
to be picked.

letterCount.set(letter, count);
}

for (const cha of input){

Choose a reason for hiding this comment

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

I might like to see something like 'inputLetter'-- I think 'cha' is short for 'character', here? ('character' may be a reserved word in javascript-- I'd have to double check)

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