Skip to content

Instantly share code, notes, and snippets.

@nodox nodox/
Last active Aug 29, 2018

What would you like to do?


if I wanted to make something lowercase I would do this

const x = (name) => 
  name = name.toLowerCase()

But since its one parameter is there a way i could make it lowercase without specifying the parameter? Since arrow functions dont require it for one parameter.

const x = () => // can i put anything here? Or do i have to define a parameter.


const x = (name) => name = name.toLowerCase()

This means that your function returns a variable that is assigned the arugment in lowercase form. I guess that could work--let me know the output--however when you read the function as I did it doesn't make much sense. Another problem here is that the new name variable actually references the argument, so oyu are overriding the argument and then returning it which is not a good practice. Because if you ever want the original value you will have lost it.

So let's actually write out what we want to do verbally.

I want a constant variable to be assigned a function. The function takes a parameter called name and returns the lowercase version of the string.

const myFunction = name => name.toLowercase()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.