1
1
/*
2
- Explanation :- a user gives a String (it can be incomplete lower or
3
- partial lower ) and then the program would convert it into a
4
- complete (all characters in upper case) upper case string. The
5
- logic we have used in the following program is: All the lower case
6
- characters (a-z) has ASCII value ranging from 97 to 122 and their
7
- corresponding upper case characters (A-Z) have ASCII values 32
2
+ Explanation :- A user gives a string (it can be incomplete lowercase or
3
+ partially in lowercase ) and then the program converts it into a
4
+ completely (all characters in uppercase) uppercase string. The
5
+ logic we have used in the following program is: All the lowercase
6
+ characters (a-z) has [ ASCII](https://en.wikipedia.org/wiki/ASCII) value ranging from 97 to 122 and their
7
+ corresponding uppercase characters (A-Z) have ASCII values 32
8
8
lesser than them. For example ‘a‘ has an ASCII value of 97
9
9
and ‘A‘ has an ASCII value of 65 (97 - 32). The same applies to other
10
10
characters.
11
11
*/
12
12
13
13
/**
14
- * UpperCaseConversion takes any case-style string and converts it to the upper case -style string.
15
- * @param {String } inputString any case style string
16
- * @returns {String } upper case string
14
+ * upperCaseConversion takes any case-style string and converts it to the uppercase -style string.
15
+ * @param {string } inputString Any case style string
16
+ * @returns {string } Uppercase string
17
17
*/
18
- const UpperCaseConversion = ( inputString ) => {
18
+ const upperCaseConversion = ( inputString ) => {
19
19
// Take a string and split it into characters.
20
20
const newString = inputString . split ( '' ) . map ( char => {
21
21
// Get a character code by the use charCodeAt method.
22
22
const presentCharCode = char . charCodeAt ( )
23
- // If the character code lies between 97 to 122 it means they are in the lower case so convert it.
23
+ // If the character code lies between 97 to 122, it means they are in the lowercase so convert it.
24
24
if ( presentCharCode >= 97 && presentCharCode <= 122 ) {
25
25
// Convert the case by use of the above explanation.
26
26
return String . fromCharCode ( presentCharCode - 32 )
@@ -32,4 +32,4 @@ const UpperCaseConversion = (inputString) => {
32
32
return newString . join ( '' )
33
33
}
34
34
35
- module . exports = UpperCaseConversion
35
+ export { upperCaseConversion }
0 commit comments