Skip to content

Leaves - Samantha #30

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Leaves - Samantha #30

wants to merge 6 commits into from

Conversation

iamsammysam
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? I was able to use loops, if statements, arrays and objects (behaving as hashes) to write this code.
Did you need to use different strategies to find information online about JavaScript than you would for Ruby? I basically used the same strategies to find information online about JS that I use for Ruby. First looking at Ada's material, then looking at Javascript documentation online.
What was a challenge you were able to overcome on this assignment? Learning the right syntax was a challenge at the beginning but it felt easier as I found information about JS online and applied that to the Ruby concepts that I already have.
What has been interesting and positive about learning a new programming language? It is always interesting to learn a second or even a third language and to use the fundamental concepts of the first language to find similarities and differences and adapt to implement them to a new language.
What is something to focus on your learnings in JavaScript in the next week? I want to get more practice on the syntax and developing more complex programs in JS.

@@ -1,8 +1,68 @@
const Adagrams = {
drawLetters() {
// Implement this method for wave 1
const alphabet = 'AAAAAAAAABBCCDDDDEEEEEEEEEEEEFFGGGHHIJKLLLLMMNNNNNNOOOOOOOOPPQRRRRRRSSSSTTTTTTUUUUVVWWXYYZ';

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 might store a hash of letter frequencies like this

letterQuantities: {
  A: 9, B: 2, ...
}

const alphabet = 'AAAAAAAAABBCCDDDDEEEEEEEEEEEEFFGGGHHIJKLLLLMMNNNNNNOOOOOOOOPPQRRRRRRSSSSTTTTTTUUUUVVWWXYYZ';
const lettersInHand = [];

for (let i = 0; i < 10; i++) {

Choose a reason for hiding this comment

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

There's a small bug here. Consider how you could make sure you don't pick the same letter 10 times (however unlikely it is).


for (let i = 0; i < (input.length); i++) {
if (lettersInHand.includes(input[i]) === false) {
result = false;

Choose a reason for hiding this comment

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

since you used a traditional for loop you could simply return false here so you don't unnecessarily need to go through the whole loop.

},

scoreWord(word) {
const score = { A:1, E:1, I:1, O:1, U:1, L:1, N:1, R:1, S:1, T:1, D:2, G:2,

Choose a reason for hiding this comment

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

style note: put each key-value pair on one line.

// The function indexOf finds the value for the index with the max value
let correct = { word: words[scores.indexOf(Math.max.apply(null, scores))], score: Math.max.apply(null, scores) };

// Still need to work on the tie-breaking rules for Wave 4:

Choose a reason for hiding this comment

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

You've got a good start!

@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 nice start!
Appropriately handles edge cases for tie-breaking logic no
All tests for highestScoreFrom pass no
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 comments for you to review (including a bug in tiebreaker), but overall you’ve done a great job of practicing syntax.

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