toLowerCase question

Hello, why does toLowerCase not work on the second console.log?
It returns “Rats”.

function lowerCase(text){
  //tolowercase
    let text2=text.toLowerCase();
    console.log(text2)
  //tolowercase - Doesn't work
    text.toLowerCase();
    console.log(text)
}
console.log(lowerCase("Rats"))

It’s a method of a string, not a function. Review how to use is here:

https://www.w3schools.com/jsref/jsref_toLowerCase.asp

It’s also called toLowerCase() not lowerCase()

1 Like

Thank you very much~

your function lowerCase is not returning anything, so this

always shows undefined

this one will not change the text variable to be lowercase, the toLowerCase method returns a new string, doesn’t change the string it is used on

1 Like