-1

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

name = "world"
puts "Hello, #{name}!"
Julie
  • 34
  • 4

1 Answers1

3

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
brk
  • 48,835
  • 10
  • 56
  • 78
IndiGan
  • 96
  • 9