Skip to content

Stacy's JS Adagrams vanilla fiah#39

Open
StacyLundquist wants to merge 6 commits into
Ada-C14:masterfrom
StacyLundquist:master
Open

Stacy's JS Adagrams vanilla fiah#39
StacyLundquist wants to merge 6 commits into
Ada-C14:masterfrom
StacyLundquist:master

Conversation

@StacyLundquist

Copy link
Copy Markdown

Assignment Submission: JS Adagrams

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Prompt Response
What patterns were you able to use from your Ruby knowledge to apply to JavaScript? Finding the handy dandy underscore addition allowed me to use some of the built-in helper methods that were so ...helpful with Ruby, with JS.
Did you need to use different strategies to find information online about JavaScript than you would for Ruby? Yes, it seemed like a lot of the JS was more advanced or just harder for me to understand. It was easier for me to search for a Ruby function with 'to javascript' at the end.
What was something you needed to do independent research on for this project? What did you learn? I think the underscore.js counts here? I need to do more research about classes; I attempted it, but was unsuccessful.
What was a challenge you were able to overcome on this assignment? Knowing how to get started. I struggle with analysis paralysis and often don't know how to start projects. This time I had a plan and jumped right in! I was wrong, but it got the code juices flowing until someone could help me.
What has been interesting and positive about learning a new programming language? It's fun to see the similarities and differences!
What is something to focus on your learnings in JavaScript in the next week? Classes, closures, and arrow functions!

@beccaelenzil beccaelenzil left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

JS Adagrams

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly uses variables, and only uses const and let variables. The program prefers const variables. The program never uses var. ✔️
Practices best-practices in JavaScript syntax. There are semi-colons at the end of most lines that need semi-colons. Variables and functions are named with camelCase. ✔️
Correctly creates and calls functions within an object with proper syntax (parameters, return statements, etc.) ✔️
Uses correct syntax for conditional logic and iteration ✔️
Practices git with at least 3 small commits and meaningful commit messages ✔️
Utilizes unit tests to verify code; tests can run using the command $ npm test test/adagrams.test.js and we see test successes and/or failures ✔️

Functional Requirements

Functional Requirement yes/no
For the drawLetters function, there is an appropriate data structure to store the letter distribution. (You are more likely to draw an 'E' than an 'X'.) ✔️
Utilizes unit tests to verify code; all tests for drawLetters and usesAvailableLetters pass ✔️
Utilizes unit tests to verify code; all tests for scoreWord pass ✔️
Utilizes unit tests to verify code; all tests for highestScoreFrom pass ✔️

Overall Feedback

Great work on this project! In this project you’ve taken some interesting logic and worked it into JavaScript syntax. Your code is very clear and readable. Nice work!

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 5+ in Code Review && 3+ in Functional Requirements ✔️

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Comment thread src/adagrams.js
Comment on lines +9 to +14
const addLetters = function (letters, frequency) {
letters.forEach(function (letter) {
for (let i = 0; i < frequency; i++) {
letterPool.push(letter);
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As an arrow function, this would look like this:

Suggested change
const addLetters = function (letters, frequency) {
letters.forEach(function (letter) {
for (let i = 0; i < frequency; i++) {
letterPool.push(letter);
}
})
const addLetters = (letters, frequency) => {
letters.forEach(function (letter) {
for (let i = 0; i < frequency; i++) {
letterPool.push(letter);
}
})

Comment thread src/adagrams.js
drawLetters() {
// Implement this method for wave 1
const letterPool = [];
const addLetters = function (letters, frequency) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a clever little helper function and a creative way to dynamically fill the letterPool.

Comment thread src/adagrams.js

const inHandHash = {}
lettersInHand.forEach((letter) => {
inHandHash[letter] === undefined ? inHandHash[letter] = 1 : inHandHash[letter]++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of a ternary

Comment thread src/adagrams.js
valid = false;
} else if (inHandHash[checkLetter] >= 1) {
inHandHash[checkLetter] -= 1;
} else {valid = false;}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider moving valid = false to create more consistency with your syntax and increase readability.

Comment thread src/adagrams.js
Comment on lines +126 to +132
if (topWord.length === 10 && highestScore.word.length !== 10) {
highestScore.score = topScore;
highestScore.word = topWord;
} else if (topWord.length < highestScore.word.length && highestScore.word.length !== 10) {
highestScore.score = topScore;
highestScore.word = topWord;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice, clean logic! Consider breaking this out into it's own helper function called tieBreaker.

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