Skip to content
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

C22 Sphinx Izzy #27

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

C22 Sphinx Izzy #27

wants to merge 12 commits into from

Conversation

ihirad
Copy link

@ihirad ihirad commented Nov 27, 2024

No description provided.

Copy link

@mikellewade mikellewade left a comment

Choose a reason for hiding this comment

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

Nice work! Please let me know if there are any questions about the comments made.

@@ -1,15 +1,107 @@
'use strict';

import { letterPool, scoreChart } from './constants.js';

Choose a reason for hiding this comment

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

Comment on lines +10 to +14
for (const [letter, freq] of Object.entries(letterPoolDict)) {
for (let i = 0; i < freq; i++) {
letterPoolList.push(letter);
}
}

Choose a reason for hiding this comment

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

Something extra to think about is how you could implement this same functionality with the ... syntax that is provided and if you think it provides any advantages against what you have.

const removeLetter = (list, letter) => {
//Function has two parameters, a list and a letter, and returns a list with the letter removed
const index = list.indexOf(letter);
list.splice(index, 1);

Choose a reason for hiding this comment

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

These are letter counts will the same size but what if they weren't? What if the input size varied? What would be the time complexity of your code? What CS fundamentals data structure did we learn about that is handy for keeping track of the number of occurrences? Is there anything we can cross reference this data structure to?

//Function has one parameter, a dictionary, and returns a list of letters.
let letterPoolList = [];

for (const [letter, freq] of Object.entries(letterPoolDict)) {

Choose a reason for hiding this comment

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

Nice work finding the javascript version of .items!

Comment on lines +32 to +39
const drawnLetters = [];
for (let i = 0; i < 10; i++) {
const randomIndex = getRandomNumber(letterPoolList.length - 1);
const letter = letterPoolList[randomIndex];
drawnLetters.push(letter);

removeLetter(letterPoolList, letter);
}

Choose a reason for hiding this comment

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

Love this functionality, you separate concerns, making your more digestible!

// Implement this method for wave 2
// Function checks if the input word uses available letters in the letterInHand list
const wordUpperCase = input.toUpperCase();
const temporaryLetterBank = [...lettersInHand];

Choose a reason for hiding this comment

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

... syntax!

Comment on lines +60 to +73
// Function scores the word
const inputUpperCase = word.toUpperCase();
let score = 0;

for (const letter of inputUpperCase) {
if (scoreChart[letter]) {
score += scoreChart[letter];
}
}
if (inputUpperCase.length >= 7) {
score += 8;
}
return score;
};

Choose a reason for hiding this comment

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

⭐️

Comment on lines +75 to +94
const findHighestScore = (words) => {
//Function finds the max word score in the list
const max = words.reduce((prev, current) => {
if (scoreWord(current) > scoreWord(prev)) {
return current;
} else if (scoreWord(current) === scoreWord(prev)) {
if (current.length === prev.length) {
return prev;
} else if (current.length === 10) {
return current;
} else if (prev.length === 10) {
return prev;
} else if (current.length < prev.length) {
return current;
}
}
return prev;
}, words[0]);

return max;

Choose a reason for hiding this comment

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

Love to see you using the reduce method, you did good with this! ⭐️

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