string concatenation using javascript

html, javascript

Solution

You're re-setting the variable on this last line:

htmlString = '</html>';

Add a `+` and it'll work:

var htmlString = '<html>';
var headerString = "image1";
var sImage = "Android_images/" + headerString + ".png";
htmlString += '<img src="' + sImage + '" />';
htmlString += '</html>';

Also, why are there `<html>` tags here?

Problem

I'm trying to build a HTML string in the following way: ``` htmlString = '<html>'; var headerString = "image1"; var sImage = "Android_images/"+headerString+".png"; htmlString += '<img src='+sImage+' />'; htmlString = '</html>'; ``` I need to dynamically append a image string, but it shows: ``` <img src=Android_images/dfdfd.png /> ```

Original source

Related problems