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

Yuri-Scrabble.js #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions scrabble.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
var Scrabble = function() {};
var Scrabble = {
a: 1,
e: 1,
i: 1,
o: 1,
u: 1,
l: 1,
n: 1,
r: 1,
s: 1,
t: 1,
d: 2,
g: 2,
b: 3,
c: 3,
m: 3,
p: 3,
f: 4,
h: 4,
v: 4,
w: 4,
y: 4,
k: 5,
j: 8,
x: 8,
q: 10,
z: 10,

// YOUR CODE HERE
Scrabble.prototype.helloWorld = function() {
return 'hello world!';
score: function(word) {
//convert input word to lowercase to that score is not case-senstive
this.word = word.toLowerCase();

//iterate through input word
var letter, i, sum = 0;
for(i = 0; i < this.word.length; i++) {
letter = this.word[i];
//add the number that matches word[i] letter to sum from Scrabble properties
sum += Scrabble[letter];
}
return sum;
}
};

console.log(Scrabble.score('hippo'));

module.exports = Scrabble;