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.

Writing template strings

Writing template strings - JavaScript Tutorial

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

Start my 1-month free trial

Writing template strings

- [Instructor] Another powerful feature of JavaScript that you can use are template strings. Template strings or template literals allow you to tap into the functionality of template languages to format your JavaScript code with variables. So the first thing I want to do here to get us started is I want to clean up our file a little bit. I'm kind of tired of writing our JavaScript here in the script tag, so I want to link to a file called script.js. And this is just an empty JavaScript file that is in the same directory as our index file. And this will just allow us to contain all of our JavaScript code in one place, making it a little easier to read. So here on line one, I'm going to create a function called print. The print function is going to take in an argument called first name. Then it's going to return a string of hello, which will be concatenated with the value of first name. So we'll use a comma as our…

Contents