var str = "foo";
var arr= ["the","ff","gg"];
arr[1]='<a href = "www.google.com">str</a>'
Here in line 3 it prints "str" but I want to print "foo". So how can I do this?
var str = "foo";
var arr= ["the","ff","gg"];
arr[1]='<a href = "www.google.com">str</a>'
Here in line 3 it prints "str" but I want to print "foo". So how can I do this?
It seems you want:
arr[1] = '<a href = "www.google.com">' + str + '</a>';
Inside of the string literal, str
doesn't hold any meaning.
And to print you might want to use console.log
.