-
Notifications
You must be signed in to change notification settings - Fork 169
Amethyst - Gloria W #145
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
base: main
Are you sure you want to change the base?
Amethyst - Gloria W #145
Conversation
…x at random, remove the letter after the letter has been added to the hand
…ay. The function deep copies the working hand and changes the input to all uppercase. If the letter from the input is in the hand, it is identified and spliced from the hand. If it is not in the hand it will return false.
… any point if the input letter is not in hand, it will go to return false from the conditional statement. If we iterate through the entire input then it will reach end of function and return ture
…p the points that each letter represents. Additional points are given to words more than 7 letters. A total score is returned for the word
…the word and score of the highest score. It will update the best word if the current best is not a length of 10 and if the new word has 10 letters or is smaller in length than the current best
…ad of a counter by length
…is included once then use it as a conditional
…he result in as paramater
export const drawLetters = () => { | ||
// Implement this method for wave 1 | ||
let workingLetterPool = JSON.parse(JSON.stringify(letterPool)) | ||
let hand = [] | ||
|
||
for (let i = 0; i < 10; i++){ | ||
const drawnLetter = workingLetterPool[Math.floor(Math.random()*workingLetterPool.length)] | ||
hand.push(drawnLetter) | ||
workingLetterPool.splice(workingLetterPool.indexOf(drawnLetter),1) | ||
} | ||
return hand |
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 Gloria! Great job completing JS Adagrams! Congrats on finishing your first JavaScript project 🎉
export const usesAvailableLetters = (input, lettersInHand) => { | ||
// Implement this method for wave 2 | ||
let workingLettersInHand = JSON.parse(JSON.stringify(lettersInHand)) | ||
input = input.toUpperCase() | ||
|
||
for (let letter of input) { | ||
let inHand = workingLettersInHand.includes(letter) | ||
|
||
if(inHand) { | ||
workingLettersInHand.splice(workingLettersInHand.indexOf(letter),1) | ||
} else { | ||
return false | ||
} |
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 👍🏾
export const scoreWord = (word) => { | ||
// Implement this method for wave 3 | ||
let score = 0 | ||
word = word.toUpperCase() | ||
|
||
const letterScore = { | ||
A: 1, B: 3, C: 3, D: 2, | ||
E: 1, F: 4, G: 2, H: 4, | ||
I: 1, J: 8, K: 5, L: 1, | ||
M: 3, N: 1, O: 1, P: 3, | ||
Q: 10, R: 1, S: 1, T: 1, | ||
U: 1, V: 4, W: 4, X: 8, | ||
Y: 4, Z: 10, "":0 | ||
} |
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 & scoring approach
export const highestScoreFrom = (words) => { | ||
// Implement this method for wave 4 | ||
}; | ||
let bestWord = "" | ||
let highestScore = 0 | ||
|
||
for (const word of words) { | ||
let tempScore = scoreWord(word) | ||
|
||
if (tempScore > highestScore) { | ||
highestScore = tempScore | ||
bestWord = word | ||
} else if (tempScore === highestScore) { | ||
if(bestWord.length != 10 && (word.length === 10 || word.length < bestWord.length)){ |
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 ✅
No description provided.