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

Yasmin - JavaScript Scrabble #37

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

Conversation

bellewether
Copy link

I had a hard time getting the hang of scope the variables and functions in Javascript. By messing around with the way the function was defined I was able to call the scoreThisWord function in the Player object (even though it had been defined in the Scrabble object), but I don't know why it works and if that was an acceptable way to do it. Instead of "Scrabble.prototype.scoreThisWord = ", I used "Scrabble.scoreThisWord = ".

@kariabancroft
Copy link

To the question/comment in your PR description, the .prototype piece is what allows the function to be called on the object in which you are adding the prototype to. Not sure if that clarifies or makes it more confusing :-D

var word = word.toLowerCase();

for (var i = 0; i < word.length; i++) {
for (var j in scoreChart) {

Choose a reason for hiding this comment

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

This is one way to do this but pretty inefficient - any ideas on how to optimize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants