String interpolation


#1

Hi guys!

I just come to this problem, I was going to String interpolation exercice, and I wrote my name, it’s Luís btw, so the thing is, the output it gave was “Lus”. It’s Like my fowardtick mess with the string interpolation.

Is it something expected? How can it be avoided?

Thank you!


#2

You need to use a special ‘Escape’ code for this.

The ASCII number for the i in your name is 236 - I converted this to hexadecimal: ED

Try this:

const myName = ‘Lu’+’\u00ED’+‘s’;

const myCity = ‘Angra do Herosmo’;
console.log(My name is ${myName}. My favorite city is ${myCity});

The output I got was:

My name is Luís. My favorite city is Angra do Herosmo