Skip to content
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

pipes | tanisha | js-scrabble #33

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

pipes | tanisha | js-scrabble #33

wants to merge 5 commits into from

Conversation

tanham
Copy link

@tanham tanham commented Nov 17, 2017

JS Scrabble

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? The patterns that I notice so far are how the different kinds of for loops in Javascript relate to the loops in Ruby.
What was a challenge you were able to overcome on this assignment? I was able to begin thinking about ways to dry up my code by making use of JS built ins like indexOf and array.reduce.
What is your favorite thing about learning a new programming language? It's been cool related new Javascript concepts to Ruby concepts that I understand better like the keywords this and self
What is your least favorite thing about learning a new programming language? with little practice it is hard to get JavaScript to do what I want it to do
Do you have any recommendations on how we could improve this project for the next cohort? I would have like more coverage on using Javascript in an object oriented way.

@droberts-sea
Copy link

JS Scrabble

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
score calculates score, has appropriate params and return value yes
highestScoreFrom calculates highest scoring word, has appropriate params and return value yes - one test is still failing!
Player object
Has name and plays properties yes
Has play, totalScore, hasWon functions yes
Has highestScoringWord and highestWordScore functions yes
Overall Good work overall!

score: function(word) {
// TODO: implement score
// TODO: implement score //score(word): returns the total score value for the given word. The word is input as a string (case insensitive). The chart below shows the point value for a given letter

Choose a reason for hiding this comment

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

You should remove TODOs once they're done


if (regex.test(word) != true) {
throw 'Error';
}

Choose a reason for hiding this comment

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

Two comments here. First, instead of writing != true it would be more succinct to say if (!regex.test(word)).

Second, you should provide a more detailed description of what went wrong. Error by itself doesn't help much trying to debug.

for (let word of arrayOfWords) {
wordScore = this.score(word);
scores.push(wordScore);
}

Choose a reason for hiding this comment

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

This algorithm ends up being a little over-complicated. By my reading, your steps are:

  1. Calculate a score for every word
  2. Find those words that share the highest score
  3. Use apply tie-breaking logic to those words

A simpler algorithm is to iterate through the list of words, keeping track of the best word / score seen so far. For each word:

  • If the current word has a higher score than the best word, it's the new best word
  • If the best word has a higher score, keep it
  • If the two are tied, apply tie-breaking logic, favoring the existing best word.

This single-pass approach is more concise and (in my opinion) easier to understand.

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