Sha256: e0bf2fd88d6079b95a4e1d5cc72c27c1c58262f2546121ca04a350a38d10d38a

Contents?: true

Size: 536 Bytes

Versions: 37

Compression:

Stored size: 536 Bytes

Contents

interface LetterScore {
    [key: string]: number
}

const letterScores: LetterScore = {
  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
}

const score = (word: string): number => {
    word = word ? word.toLowerCase() : ''

    let output = 0
    word.split('').forEach((letter: string): void => {
        output += letterScores[letter]
    })

    return output
}

export default score

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
trackler-2.1.0.48 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.47 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.46 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.45 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.44 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.43 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.42 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.41 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.40 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.39 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.38 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.37 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.36 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.34 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.33 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.32 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.31 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.30 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.29 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts
trackler-2.1.0.28 tracks/typescript/exercises/scrabble-score/scrabble-score.example.ts