Coder Social home page Coder Social logo

js-scrabble's Introduction

Scrabble with JavaScript!

We are going to rebuild our Scrabble project using our knew knowledge of JavaScript.

This is an individual Stage 1 project.

Due: Fri before class, 5/18

Project Expectations

From the project root, you should be able to execute your code with node scrabble.js. Each function you create should be a method of the Scrabble object.

Project contents

This repository contains an empty node project which contains some structure to get you started. To finish setting up, go to the command line and run:

npm install

Testing

This project contains a set of tests written using the Jest test framework. Use these tests to enable a test-driven development workflow. To run the tests use the command:

npm test

It will generate a code coverage report in a coverage directory.

Error Handling

Here is one question that's always worth asking: what should your code do when given invalid input?

There are many possible answers to this question, but according to the tests these methods should throw an exception. The syntax for doing so in JavaScript is a little different than in Ruby but the high level philosophy is the same. Go do some research and figure it out!

Score chart

Letter Value
A, E, I, O, U, L, N, R, S, T 1
D, G 2
B, C, M, P 3
F, H, V, W, Y 4
K 5
J, X 8
Q, Z 10

Wave 1

Primary Requirements

Create the following methods within the Scrabble object.

  • 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.
  • highestScoreFrom(arrayOfWords): returns the word in the array with the highest score.
    • Note that it’s better to use fewer tiles, so if the top score is tied between multiple words, pick the one with the fewest letters.
    • Note that there is a bonus (50 points) for using all seven letters. If the top score is tied between multiple words and one used all seven letters, choose the one with seven letters over the one with fewer tiles.
    • If the there are multiple words that are the same score and same length, pick the first one in supplied list.

You should write your code in the Scrabble object. In addition to the provided tests, you should test the methods manually to ensure they work properly.

You can run your scrabble.js file by typing:

$ node scrabble.js

Wave 2

Primary Requirements

Create a new Player class within the Scrabble object. The class should have the following methods:

  • Constructor: Called when you use new Scrabble.Player(name), sets up an instance with the instance variable name assigned
  • name: property which returns the value of the player's name
  • plays: property which returns an Array of the words played by the player
  • play(word): method which adds the input word to the plays Array
    • Returns false if player has already won
  • totalScore(): method which sums up and returns the score of the players words
  • hasWon(): method which returns true if the player has over 100 points, otherwise returns false
  • highestScoringWord(): method which returns the highest scoring word the user has played
  • highestWordScore(): method which returns the highestScoringWord score

You will notice many of the tests for Player are incomplete. You are expected to fill in the stubbed out tests.

Optional Enhancements

  • Create a Scrabble.TileBag object that includes functionality that allows us to drawTiles and determine the remaining tiles. Beginning Tile Quantities:
Tiles per letter Letters
1 J, K, Q, X, Z
2 B, C, F, H, M, P, V, W, Y
3 G
4 D, L, S, U
6 N, R, T
8 O
9 A, I
12 E
  • Create a Dictionary class that includes a method for searching a list of words to determine if a given word is a valid word.
  • Create a Board class that has a matrix (array of arrays) of tile places. Check if a word can be played on a given tile place in a certain direction.
  • Using the existing tests as an example, write some tests for your optionals!

What Instructors Are Looking For

Check out the feedback template which lists the items instructors will be looking for as they evaluate your project.

js-scrabble's People

Contributors

cheezitman avatar torshimizu avatar kariabancroft avatar tildeee avatar hamled avatar jnf avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.