Find ASCII Charcode of Inverse Case Character

Published by Matt in

Create a function that takes a single character as an argument and returns the char code of its lowercased / uppercased counterpart.

Examples

Given that:
  - "A" char code is: 65
  - "a" char code is: 97

counterpart_char_code("A") ➞ 97

counterpart_char_code("a") ➞ 65

Notes

  • The argument will always be a single character.
  • Not all inputs will have a counterpart (e.g. numbers), in which case return the input's char code.
Watch a quick demo on how Edabit works.