Skip to content

Commit

Permalink
Update to use class method
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras committed Jan 6, 2024
1 parent 5d0e538 commit a580a34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/isogram/.meta/example.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Isogram
isIsogram: (phrase) ->
@isIsogram: (phrase) ->
seen = {}
for char in phrase.toLowerCase()
cp = char.charCodeAt(0)
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/isogram/isogram.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Isogram
isIsogram: (phrase) ->
@isIsogram: (phrase) ->

module.exports = Isogram
29 changes: 14 additions & 15 deletions exercises/practice/isogram/isogram.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,73 +1,72 @@
Isogram = require './isogram'

describe 'Isogram', ->
iso = new Isogram()
it 'empty string', ->
phrase = ''
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual true

xit 'isogram with only lower case characters', ->
phrase = 'isogram'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual true

xit 'word with one duplicated character', ->
phrase = 'eleven'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'word with one duplicated character from the end of the alphabet', ->
phrase = 'zzyzx'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'longest reported english isogram', ->
phrase = 'subdermatoglyphic'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual true

xit 'word with duplicated character in mixed case', ->
phrase = 'Alphabet'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'word with duplicated character in mixed case, lowercase first', ->
phrase = 'alphAbet'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'hypothetical isogrammic word with hyphen', ->
phrase = 'thumbscrew-japingly'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual true

xit 'hypothetical word with duplicated character following hyphen', ->
phrase = 'thumbscrew-jappingly'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'isogram with duplicated hyphen', ->
phrase = 'six-year-old'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual true

xit 'made-up name that is an isogram', ->
phrase = 'Emily Jung Schwartzkopf'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual true

xit 'duplicated character in the middle', ->
phrase = 'accentor'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'same first and last characters', ->
phrase = 'angola'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

xit 'word with duplicated character and with two hyphens', ->
phrase = 'up-to-date'
result = iso.isIsogram(phrase)
result = Isogram.isIsogram(phrase)
expect(result).toEqual false

0 comments on commit a580a34

Please sign in to comment.