We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d18bcda commit 52eee8aCopy full SHA for 52eee8a
Strings/LowercaseToUppercase.js
@@ -0,0 +1,26 @@
1
+// upper converts lowercase sting to upper case
2
+// input is 1 string i.e. str
3
+const upper = (str) => {
4
+ // check that inputs are string
5
+ if (typeof str !== "string") {
6
+ return "Not string(s)";
7
+ }
8
+
9
+ var convertedString = "";
10
11
+ for (let i = 0; i < str.length; i++) {
12
+ if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122) {
13
+ convertedString =
14
+ convertedString + String.fromCharCode(65 + str.charCodeAt(i) - 97);
15
+ continue;
16
17
+ convertedString = convertedString + str.charAt(i);
18
19
20
+ return convertedString;
21
+};
22
23
+console.log(upper("abcd")); // should print ABCD
24
+console.log(upper("abcd1")); // should print ABCD1
25
+console.log(upper("*abcd")); // *ABCD
26
+console.log(upper("aBs")); // should print ABS
0 commit comments