Home » Javascript » Javascript string interpolation like in ruby

Javascript string interpolation like in ruby

Posted by: admin September 20, 2018 Leave a comment

Questions:

I am having the following code in my JS.

$('#ytResultsList').append('<li><a href="https://www.youtube.com/watch?v="' + item.id.videoId + '></a></li>');

As you can see from the above code, in HTML the result is like below.

<li><a href="https://www.youtube.com/watch?v=" bruvbiwlwfi=""></a></li>

I want the URL to be like below in HTML.

"https://www.youtube.com/watch?v=bruvbiwlwfi" 

How can I do this in Javascript?

Answers: