From the course: Learning ECMAScript 6+ (ES6+)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Enhancing object literals

Enhancing object literals - JavaScript Tutorial

From the course: Learning ECMAScript 6+ (ES6+)

Start my 1-month free trial

Enhancing object literals

- [Instructor] Think about an object, any object. Mine is going to be a skier. What I want to do is I want to build a function that is going to return an object that's going to return this skier. So the skier will take in a name and a sound. Something that they yell when they're excited about skiing. And the skier will then return an object that builds together the name and the sound and a powder yell. So powder yell just means if it's really snowy, you're going to get excited and you have to yell. So we're going to go ahead and use let yell and I'll set that equal to this.sound.touppercase so it'll take that sound string and make it uppercase. And then we'll console log the message using a template string. Now when I call this function here on line 12, I'm going to send it a name and then I'll send it some sort of yell. Now we see that skier is a function that we've created. Let's go ahead and console log the skier…

Contents