str = 'z' n = (str == str.toLowerCase()) ? 96 : 64 result = str.charCodeAt(0) - n console.log(result);