Html

can any help me https://www.codecademy.com/courses/introduction-to-javascript/lessons/introduction-to-javascript/exercises/built-in-methods
thanks

Which instruction are you stuck on?

this is what i don’t get
Use the .toUpperCase() method to log the string 'Codecademy' to the console in all capital letters.

Is the method not introduced in the lesson narrative? It is one of what we refer to as, string methods. A string is data type, and types are defined by classes (in JS they are prototypes, but let’s leave this for now). A class is defined with methods to work on its object instances. So a string (character string) is a class instance that inherits its methods from the parent class, String and has the data type, 'string'.

Ignore the above and just focus on the method in the instruction. Since it is a string method, and methods are properties of an object, what object should precede the method call? Answer: a string.

'string'.toUpperCase()

which will yield,

'STRING'

When we read log to the console we only need to think, console.log(). Notice that .log() is a method, also, and its owner object is ‘console’.

console.log('string'.toUpperCase())

or if you like,

const a = 'string'
console.log(a.toUpperCase())

or if you like,

const b = a.toUpperCase()
console.log(b)

The key is to know the type of object, and that will tell us what methods it has in its prototype. Again, skip this and focus on the mechanics and the relation of the property to the object.

object.property

or,

object.method()
2 Likes