Skip to content

Earth - Kal#40

Open
kashenafi wants to merge 4 commits into
Ada-C14:masterfrom
kashenafi:master
Open

Earth - Kal#40
kashenafi wants to merge 4 commits into
Ada-C14:masterfrom
kashenafi:master

Conversation

@kashenafi

@kashenafi kashenafi commented Dec 14, 2020

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? I was able to associate the "hash" we used in our Ruby Adagrams with the "object" in Javascript. The pattern of using variables felt the same, with the addition of the "let" and "const".
Did you need to use different strategies to find information online about JavaScript than you would for Ruby? Tried to stick to the official MDN docs as much as I could.
What was something you needed to do independent research on for this project? What did you learn? Struggles with for...of vs for...in loop, which required quite a bit of debugging.
What was a challenge you were able to overcome on this assignment? Seeing how many concepts apply to many different syntaxes.
What has been interesting and positive about learning a new programming language? Getting comfortable with living in what feels like a bracket jungle.
What is something to focus on your learnings in JavaScript in the next week? Learning more about how tests work.

@dHelmgren dHelmgren 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

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 5+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 4+ in Code Review && 2+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-3 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention

Comment thread src/adagrams.js
wordStats.sort(function (a, b) {
return b.score - a.score;
});
console.log(wordStats);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the future, it's bets to remove debugging statements from your submitted code! It makes the test results a lot messier to check!

Comment thread src/adagrams.js
// Wave 1
drawLetters() {
// Implement this method for wave 1
const letterPool = ('A'.repeat(10) + 'B'.repeat(2) + 'C'.repeat(2) + 'D'.repeat(4) + 'E'.repeat(12) + 'F'.repeat(2) + 'G'.repeat(3) + 'H'.repeat(2) + 'I'.repeat(9) + 'J' + 'K' + 'L'.repeat(4) + 'M'.repeat(2) + 'N'.repeat(6) + 'O'.repeat(8) + 'P'.repeat(2) + 'Q' + 'R'.repeat(6) + 'S'.repeat(4) + 'T'.repeat(6) + 'U'.repeat(4) + 'V'.repeat(2) + 'W'.repeat(2) + 'X' + 'Y'.repeat(2) + 'Z').split('');

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 very Javascript way to build the letter pool. I like it! 😁

Comment thread src/adagrams.js
Comment on lines +7 to +12
do {
let newIndex = Math.floor(Math.random() * letterPool.length);
if (!letterHandIndices.includes(newIndex)) {
letterHandIndices.push(newIndex) }
}
while (letterHandIndices.length < 10);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do while loops aren't super popular in most js workplaces. You could rewrite this as a vanilla while loop like so:

Suggested change
do {
let newIndex = Math.floor(Math.random() * letterPool.length);
if (!letterHandIndices.includes(newIndex)) {
letterHandIndices.push(newIndex) }
}
while (letterHandIndices.length < 10);
while (letterHandIndices.length < 10){
let newIndex = Math.floor(Math.random() * letterPool.length);
if (!letterHandIndices.includes(newIndex)) {
letterHandIndices.push(newIndex) }
}

Comment thread src/adagrams.js
Comment on lines +39 to +49
const scores = {
"AEIOULNRST": 1,
"DG": 2,
"BCMP": 3,
"FHVWY": 4,
"K": 5,
"JX": 8,
"QZ": 10
}
const wordArray = word.toUpperCase().split('');
let wordScore = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dang, super DRY!

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