function Main(input) { let output = ''; for (var i = 0; i < input.length; i++) { let char = input.charAt(i); judgeCase(char); } function judgeCase(char) { let lowerRegexp = new RegExp(/[a-z]/, 'g'); if (char.match(lowerRegexp)) { char = char.toUpperCase(); } else { char = char.toLowerCase(); } output += char; } console.log(output); } Main(require('fs').readFileSync('/dev/stdin', 'utf8'));