DEV Community

Discussion on: HELP // Trying to print even and odd numbers

Collapse
 
nickytonline profile image
Nick Taylor • Edited

Based on your current code, the easiest thing to do would be to modify this line

numberDiv.innerHTML = numberArray;
Enter fullscreen mode Exit fullscreen mode

to

numberDiv.innerHTML = numberArray.join('’);
Enter fullscreen mode Exit fullscreen mode

Also, the reason the comma appears under your paragraph with spacing is because the paragraph element’s style for display is block. The comma is just a text node in the DOM.

In terms of the best way to do this, updating innerHTML With a joined array seems fine.

Hope that helps!

Collapse
 
ja profile image
Joe Ashwell

Ahhh awesome! Got it all working now, thanks for your help!

N.B. There was a small error in your code above, just an apostrophe and a back tick in the brackets, as opposed to two apostrophes. - I wasn't sure if you were trying to catch me out 😂.

Thanks again Nick, much appreciated!

Collapse
 
nickytonline profile image
Nick Taylor

Ah, I was on mobile. I must have picked the wrong one when closing the empty string. Glad it’s all sorted.