I’m just wondering why sometimes to put a blank () at the end of code. For example when I do .toUpperCase it doesn’t work without it having () at the end like this .toUpperCase()
Not yet, does it explain it there?
Yes. Essentially, functions are blocks of repeatable code. In your example, toUpperCase
is the name of a function. Adding the ()
calls or invokes the function (executes the repeatable code). Some functions take arguments. Those arguments would be place inside the ()
. toUpperCase
doesn’t require any arguments, so the ()
are left empty. If you find this confusing, don’t worry. It will make sense once you learn about functions.