Shipswake
Shipswake

Reputation: 11

Typescript Quickstart Tutorial

I am working with Visual Studio 2015, ASP.NET Core

When I walkthrough the Typescript Tutorial version 2.0.6.0 I have a problem with the function sayHello not producing the correct output.

function sayHello() {
    const compiler = (document.getElementById("compiler") as HTMLInputElement).value;
    const framework = (document.getElementById("framework") as HTMLInputElement).value;

    return "Hello from ${compiler} and ${framework}!";
}

When I edit a textbox I see the following output:

Hello from ${compiler} and ${framework}!

The variables are not replaced as would be expected.

Does anyone have any idea what could be wrong here?

Upvotes: 1

Views: 132

Answers (1)

jrbedard
jrbedard

Reputation: 3730

You have to use template strings surrounded by backtick/backquote (`) characters to embed expressions within.

return `Hello from ${compiler} and ${framework}!`;

Upvotes: 1

Related Questions