Skip to content

Conversation

Kalakalot
Copy link

JS Adagrams

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What patterns were you able to use from your Ruby knowledge to apply to JavaScript? Conditionals, times(Ruby)/for(JavaScript) loops, each(Ruby)/for each (JavaScript) loops, hash maps (particularly for counting occurrences), and adding values to a variable (such as when tallying a score).
Did you need to use different strategies to find information online about JavaScript than you would for Ruby? Yes -- I couldn't find any JavaScript documentation that's as well-organized as the ruby-docs.org documentation, so I ended up doing lots of keyword searches within the appropriate chapter of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide. On the other hand, so far, StackOverflow seems to be just as helpful for JavaScript as it is for Ruby.
What was a challenge you were able to overcome on this assignment? I struggled with determining why my usesAvailableLetters method was never returning true because I couldn't figure out how to test my logic in Node -- kept getting an 'illegal return statement' message because my return statement wasn't within a function. Eventually I realized I could put the relevant code in a separate JavaScript file with lots of console.log statements to see what was happening.
What has been interesting and positive about learning a new programming language? It has been amazing how fast JavaScript is going and also seeing how my programming skills in general have expanded! I remember having a really hard time with AdaGrams the first time around, but here I am, less than a week after starting JavaScript, writing a JavaScript version of the program fairly easily.
What is something to focus on your learnings in JavaScript in the next week? I want to get more familiar with the build-in methods for string, arrays, and objects.

// code for random courtesy of https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array
// pull a random letter from the letter pool array
let randomLetter = letterPoolArray[Math.floor(Math.random() * letterPoolArray.length)];
// condition: if adding the letter to the player hand would exceed the count of letters in the pool, redraw

Choose a reason for hiding this comment

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

yes! nice work on this logic and clear comments describing what's going on.

// Implement this method for wave 1
const letterPoolHash = {'A':9, 'B':2, 'C':2, 'D':4, 'E':12, 'F':2, 'G':3, 'H':2, 'I':9, 'J':1, 'K':1, 'L':4, 'N':6, 'O':8, 'P':2, 'Q':1, 'R':6, 'S':4, 'T':6,'U':4, 'V':2, 'W':2, 'X':1, 'Y':2, 'Z':1 };

const letterPoolArray = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B',

Choose a reason for hiding this comment

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

This data structure works, but it's not very DRY and would be tricky to change. For example, suppose I said you had the wrong number of "I"s - you would have to do a lot of counting to solve the problem.

Instead you could use your hash of letter frequencies to create this array dynamically.

}
});

// loop over handHash: if letter count in input is ever greater than letter count in hash, return false. Else return true.

Choose a reason for hiding this comment

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

Consider whether it would have been possible to do this check in the for loop above (had that not been a forEach loop)?

let wordArray = word.toUpperCase().split('')
let score = 0

if (wordArray.length >= 7) {

Choose a reason for hiding this comment

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

you forgot && wordArray.length <= 10)

@beccaelenzil
Copy link

JS Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions yes
Small commits with meaningful commit messages yes
Code Requirements
drawLetters method
Uses appropriate data structure to store the letter distribution see comment
All tests for drawLetters pass yes
usesAvailableLetters method
All tests for usesAvailableLetters pass yes
scoreWord method
Uses appropriate data structure to store the letter scores yes
All tests for scoreWord pass yes
Optional
highestScoreFrom method N/A
Appropriately handles edge cases for tie-breaking logic N/A
All tests for highestScoreFrom pass N/A
Overall Great work on this project! In this project you’ve taken some interesting logic and worked it into JavaScript syntax. I’m adding a few inline comments for you to review, but overall you’ve done a great job of practicing syntax.

beccaelenzil added a commit to beccaelenzil/js-adagrams that referenced this pull request Jun 2, 2022
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