Skip to content

Commit c2dcaff

Browse files
authored
Add an algorithm for checking if a string is in uppercase (#130)
1 parent ce8a694 commit c2dcaff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

text_manipulation/is.uppercase.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
is.uppercase <- function(string) {
2+
# split the string at character level
3+
string_split <- c(unlist(strsplit(string, split = "")))
4+
# check if the split string exactly matches its uppercase version
5+
check_case <- string_split == toupper(string_split)
6+
# return a boolean value based on the outcome of the check
7+
return(all(check_case))
8+
}
9+
10+
is.uppercase("BUSINESS")

0 commit comments

Comments
 (0)