This is my solution for a process review I took part in. Using TDD principles, I developed the required feature in a given time. I wrote my solution in JavaScript and used Jest to create my tests.
Mega soft weird: a company that develops a word processor
-
The feature that needs building today is a spell checker
-
It will accept a string of space seperated words and highlight words that have been mispelt. For example: "tme", ["time"] => "
tme" -
As a second parameter, it will accept the correctly spelt word in lower case.
Input | Output |
---|---|
"time", ["time"] | "time" |
"tme", ["time"] | " |
"cta", ["cat"] | " |
"Hand", ["hand"] | "Hand" |
"haNd", ["hand"] | "haNd" |
"the clock", ["the", "clock"] | "the clock" |
"teh clock", ["the", "clock"] | " |
"teh clokc", ["the", "clock"] | " |
Edge Cases | |
"" | Throw Error - "No words found." |