While map over an object remove the , ?
Looping over an object and it keep adding the , to the dom. I know with an array you can use .replace(). I cant find anything similar for objects.
5 Replies
Can you please share the code you're using? Without code no one can begin to guess what's happening
It is a lot of code, the issue is in the dayView generate mark up method
https://github.com/bsupinski/weather_app
GitHub
GitHub - bsupinski/weather_app
Contribute to bsupinski/weather_app development by creating an account on GitHub.
Oh, I see what's happening here!
Array.map()
returns a new array, but when you're injecting it into the DOM you're using Element.insertAdjacentHTML()
which requires a string. So JS is stringifying it, which by default an array is stringified as a comma-separated list.
What you want to do in dayView.js
is
This will create a string of the array items with a space as a separator instead of a comma.Man i am an idiot, I tried that, and couldnt figure out why it didnt work. But I was putting it before the map closing ).
Thank you @13eck
Thank you @13eck
👍