Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make string interpolation in javascript?

I want to know how to make string interpolation like in Ruby but in Javascript

name = "world"
puts "Hello, #{name}!"

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can use template literals by using ` (sorry, can’t put it in block code) instead of " or ':

let name = "world";
console.log("Hello, " + name); // Classical way
console.log(`Hello, ${name}`); // With template literals
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading