-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
  • 30,334
  • 10
  • 78
  • 137

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,504
  • 11
  • 47
  • 84