Everyone Can Code!

JavaScript Kata #5: MakeUpperCase


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

Link to Kata #3: DNA to RNA Conversion

Link to Kata #4: Remove First and Last Character

How do you rate this article?

1


YayoDrayber
YayoDrayber

A Yayo, A Drayber, among others.


Learn To Code With Me
Learn To Code With Me

Just started with Codewars and will be posting the solutions I came up with here and the apparent best practices.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.