const cipher = (s, k) => s.toLowerCase()
.map(c => c.charCodeAt(0) < 'a'.charCodeAt(0) || c.charCodeAt(0) > 'z'.charCodeAt(0)
: c.charCodeAt(0) > 122 - k
? String.fromCharCode(97 + (c.charCodeAt(0) + k - 1) % 122)
: String.fromCharCode(c.charCodeAt(0) + k))
I imagine that for now, the only way to decypher a phrase would be to check each word to verify that it is valid using either a dictionary or an API. Which may be a pain.
A thing that is not going to work now, but maybe it could work in the future (big "maybe" here, but bear with me for a second):
It would be super hacky, but it would allow us to use the browser dictionary (if it's not open already, in which case, we should use it) instead of having our own dictionary or having to call an API.
Unfortunately, ::grammar-error and ::spelling-error are not currently supported by any browser, so I cannot test this crazy idea at the moment.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.