Javascript - combine variables to form path

- 1 answer

Ad

I need to combine two variables and one static string to form a path to may image - see below. Please advise on how to correct the syntax:

var shortUrl = "http://www.art.com";
album_name = "art";

poster:""+shortUrl+""/""+album_name+"".jpg",

I am trying to get it to output: http://www.art.com/art.jpg

Ad

Answer

Ad

You almost had it.

shortUrl + "/" + album_name + ".jpg";

You don't need to escape slashes when they are inside a string literal.

Ad
source: stackoverflow.com
Ad