Skip to content

Conversation

laughtivity
Copy link

No description provided.

…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
…is included once then use it as a conditional
Comment on lines 16 to +25
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

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 🎉

Comment on lines 33 to +44
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
}

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 54 to +66
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
}

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

Comment on lines 83 to +94
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)){

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 ✅

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