Created
May 17, 2018 08:25
-
-
Save AndrewBestbier/7e1b622065bac9da0379cf0e9391db6f to your computer and use it in GitHub Desktop.
This file contains 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
['A', 'B', 'C'].map(element => { | |
let result; | |
if (element === 'A') { | |
result = 'a'; | |
} | |
if (element === 'B') { | |
result = 'b'; | |
} | |
if (element === 'C') { | |
result = 'c'; | |
} | |
if (element === 'D') { | |
result = 'd'; | |
} | |
if (element === 'E') { | |
result = 'e'; | |
} | |
if (element === 'F') { | |
result = 'f'; | |
} | |
if (element === 'G') { | |
result = 'g'; | |
} | |
if (element === 'H') { | |
result = 'h'; | |
} | |
if (element === 'I') { | |
result = 'i'; | |
} | |
if (element === 'J') { | |
result = 'j'; | |
} | |
if (element === 'K') { | |
result = 'k'; | |
} | |
if (element === 'L') { | |
result = 'l'; | |
} | |
if (element === 'M') { | |
result = 'm'; | |
} | |
if (element === 'N') { | |
result = 'n'; | |
} | |
if (element === 'O') { | |
result = 'o'; | |
} | |
if (element === 'P') { | |
result = 'p'; | |
} | |
if (element === 'Q') { | |
result = 'q'; | |
} | |
if (element === 'R') { | |
result = 'r'; | |
} | |
if (element === 'S') { | |
result = 's'; | |
} | |
if (element === 'T') { | |
result = 't'; | |
} | |
if (element === 'U') { | |
result = 'u'; | |
} | |
if (element === 'V') { | |
result = 'v'; | |
} | |
if (element === 'W') { | |
result = 'w'; | |
} | |
if (element === 'X') { | |
result = 'x'; | |
} | |
if (element === 'Y') { | |
result = 'y'; | |
} | |
if (element === 'Z') { | |
result = 'z'; | |
} | |
return result; | |
}); |
Thank you for your feedback. I have another attempt:
(function() {
var letters = ['A', 'B', 'C'];
var nextarray = [];
var i;
for (i = 0; i < letters.length; i++) {
var result;
var element = letters[i];
if (element === 'A') {
result = 'a';
}
if (element === 'B') {
result = 'b';
}
if (element === 'C') {
result = 'c';
}
if (element === 'D') {
result = 'd';
}
if (element === 'E') {
result = 'e';
}
if (element === 'F') {
result = 'f';
}
if (element === 'G') {
result = 'g';
}
if (element === 'H') {
result = 'h';
}
if (element === 'I') {
result = 'i';
}
if (element === 'J') {
result = 'j';
}
if (element === 'K') {
result = 'k';
}
if (element === 'L') {
result = 'l';
}
if (element === 'M') {
result = 'm';
}
if (element === 'N') {
result = 'n';
}
if (element === 'O') {
result = 'o';
}
if (element === 'P') {
result = 'p';
}
if (element === 'Q') {
result = 'q';
}
if (element === 'R') {
result = 'r';
}
if (element === 'S') {
result = 's';
}
if (element === 'T') {
result = 't';
}
if (element === 'U') {
result = 'u';
}
if (element === 'V') {
result = 'v';
}
if (element === 'W') {
result = 'w';
}
if (element === 'X') {
result = 'x';
}
if (element === 'Y') {
result = 'y';
}
if (element === 'Z') {
result = 'z';
}
nextarray.push(result);
}
return nextarray;
})();
Dat IIFE and for loop though
Back to the good old days when people wrote proper code. Make JavaScript great again 🙌
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your inputs. After many researches, I think this is the React Way:tm: to do this.
I ran this through the Dankometer and it came out moist. You are skills.