-5
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?

Chris Martin
  • 29,484
  • 8
  • 71
  • 131

1 Answers1

0

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.

Gaurang Tandon
  • 6,110
  • 10
  • 44
  • 79