Unruly array not staying in containing div
On my website I have a JS function that produces an Array that can be of varying size depending on what input is given by the use
This is what I use to display the output array, perArrary, and some text.
document.getElementById("happyanswer").innerHTML= perArray + " are so happy, yes they are!!!";
The part in quotes itself always stays in the div . When it displays the array's Elements it pushes to the right until it displays all elements.
I have the fiddle here http://jsfiddle.net/m57KC/
Right now the only button that works is the happy numbers button. You can also ignore whatever issues there still are other than this one( there are many I know).
The problem is that you are converting an array directly to a string, with no
109,103,100,97,94,91,86,82,79,70,68,49,44,32,31,28,23,19,13,10,7,1 are so happy, yes they are!!!. Commas don't trigger line-wrapping. If you join with a comma and space, instead, the line will wrap automatically:
document.getElementById("happyanswer").innerHTML= perArray.join(', ') + " are so happy, yes they are!!!";
This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here