Could you please review the code below and help me understand why I am encountering issues when trying to run the program?
$(document).ready(function() {
var comp = new Array("AAPL", "MSFT", "XRTX&");
var t = setInterval(function(){
getPrice();
},200);
});
function getPrice() {
for (var i = 0; i < comp.length; i++){
$.getJSON('https://finance.google.com/finance/info?client=ig&q=' + comp[i] + '&callback=?', function(response){
var stockInfo = response[0];
var stockString = '<div id="stockprice">';
stockString += 'Candente Copper: DNT $' + '' + stockInfo.l + '';
stockString += '</div>';
$('#stockprice').replaceWith(stockString);
$("#stockprice:contains('-')").addClass('red');
$("#stockprice:contains('+')").addClass('green');
});
}
}
Could the issue be related to my Array object, or are there other parts of the program that may have problems? It's worth noting that the code runs smoothly without referring to the array elements.
Thank you