To Uppercase

Problem

Write a program that receives a string with both uppercase and lowercase letters as input and outputs the string by unifying all uppercase letters.

input

A string is entered on the first line. The length of the string does not exceed 100.

ItisTimeToStudy

output

A unified character string with uppercase letters is output on the first line.

ITISTIMETOSTUDY

Solution

using toUpperCase()

function solution(s) {
	let answer = s.toUpperCase();
	return answer;
}

using ASCII code

function solution(s) {
	let answer = 0;

	for (let x of s) {
		let num = x.charCodeAt();
		// uppercase index is 65 ~ 90 in ASCII code
		// lowercase index is 97 ~ 122 in ASCII code

		if (num >= 97 && num <= 122) answer += x;
		// or
		if (num >= 97 && num <= 122) answer += String.fromCharCode(num - 32);
	}

	return answer;
}