I'm trying to output the data in an array (produced by this code) to a div in a simple web page, using this jquery:
$('#submit').click(function(e) {
e.preventDefault();
var num = $('#userInput').val();
var primes = sieve(num); // sieve() produces array of prime numbers
console.log(primes);
$('#answer').html(primes);
});
The console is logging the array as I would like to see it, (i.e. 2, 3, 5, 7, 11, 13, etc.) but the content in #answer is displaying without any formatting (23571113 etc.).
How can I get the data to display in a more readable format? I've tried using .split and .join to add commas or line breaks but no joy...