← Back to challenges

Find the Characters Counterpart Char Code

JavaScriptHardstringsformatting

Instructions

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

counterpartCharCode("A") ➞ 97

counterpartCharCode("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.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Ones, Threes and Nines (Version #1)