Created
May 7, 2020 18:23
-
-
Save geektutor/d2925a89e4ded6d31a969072f3bb3d86 to your computer and use it in GitHub Desktop.
Day 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
swapCase('Www.HackerRank.com'); | |
swapCase('Dart2'); | |
swapCase('HackerRank.com presents "Dart 2".'); | |
} | |
swapCase(String text) { | |
var literalList = text.split(""); | |
var output = []; | |
for (var i = 0; i < literalList.length; i++) { | |
if (literalList[i] == literalList[i].toUpperCase()) { | |
output.add(literalList[i].toLowerCase()); | |
} else { | |
output.add(literalList[i].toUpperCase()); | |
} | |
} | |
String output1 = output.join(); | |
print(output1); | |
} | |
/* | |
You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment