TextDecoder
{ const encoder = new TextEncoder() const decoder = new TextDecoder() const capitalizeASCIIalphanum = str => { const arr = encoder.encode(str) const len = arr.length let val = arr[0] if (val > 0x60) arr[0] = val - 0x20 for (let i = 1; i < len; i++) { val = arr[i] if (val < 0x5b) arr[i] = val + 0x20 } return decoder.decode(arr) } const { log } = console log(capitalizeASCIIalphanum("hello")) log(capitalizeASCIIalphanum("GREAT")) log(capitalizeASCIIalphanum("aWESOME")) }
Many checks are missing. This is intentional, because we are going to pretend that this is performant.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
TextDecoder
solution:Many checks are missing. This is intentional, because we are going to pretend that this is performant.