If you missed the introductory post, it's here. For a list of previously solved katas, please refer to the bottom of this page.
If this is your first time seeing my post, please note - these katas are probably randomly assigned per user so please don't go into Codewars thinking we will have exactly the same user experience, I am just posting these in the order that I got them.
Kata #5
DESCRIPTION:
Write a function which converts the input string to uppercase.
Starting code:
function makeUpperCase(str) {
// Code here
}
My attempt:
function makeUpperCase(str) {
// Code here
return str.toUpperCase()
}
Worked! Except for my first attempt wherein I forgot to close out the method with the opening and closing parentheses.
Best Practices, rank #1:
const makeUpperCase = str => str.toUpperCase();
Best Practices, rank #2:
function makeUpperCase(str) {return str.toUpperCase();}
And rank #3 is where my attempt rests. The thing I noticed about ranks #1 and #2 is that those who went with this approach and got the votes are the ones who insisted that they make their solution a one-liner. I also noticed that maybe I'm a fill-in-the-blanks sort of person approaching the starting code as opposed to one-liner people that do a take-down-everything-and-rebuild approach. Different strokes for different folks I guess.
That's it for Kata #5, stay tuned for more katas to be solved!
Link to Kata #1: Square(n) Sum
Link to Kata #2: Convert a Number to a String