toUpperCase() is not making the string upper case

前端 未结 7 1842
我在风中等你
我在风中等你 2021-02-11 03:10

I don\'t know what I\'m doing wrong; But somehow .toUpperCase() String-function is not working on my browser or do I get something wrong?

var string          


        
7条回答
  •  爱一瞬间的悲伤
    2021-02-11 03:39

    toUpperCase returns the new string, so you must write:

    string = string.toUpperCase();
    

    In many languages, strings are immutable, meaning that they can not be modified once created. While this costs in efficiency, it is important for object oriented programming, because if a String passed by reference to a function was modifiable, the state of objects could be changed without the object's consent.

提交回复
热议问题