News for hackers. Stuff that matters.
Re:Poll: Where do you live? by newaccount74 on Friday February 04, 2022 @04:08PM (#30213233)
I wanted a total for the US:

    console.table([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.replace(/:.*/,'').trim(), parseInt(el.nextSibling.textContent.trim())]).reduce((d, [k,v]) => {d[k]=v + (d[k] || 0); return d}, {}))
I can't figure out how to sort that, though...
Re:Poll: Where do you live? by binarynate on Friday February 04, 2022 @05:30PM (#30214292)
I created a page with the current results that includes a total for the US:

https://nate.org/hacker-news-location-poll

Re:Poll: Where do you live? by gabrielsroka on Friday February 04, 2022 @07:38PM (#30215696)
Haha, great minds think alike.

Are you accepting PRs? If so, align=right. Thanks!

To see the sorted results: https://gabrielsroka.github.io/hnpoll.html?id=30210378

Source: https://github.com/gabrielsroka/gabrielsroka.github.io/blob/...

Re:Poll: Where do you live? by Larrikin on Friday February 04, 2022 @05:59PM (#30214675)
Percentage next to totals would make this perfect
Re:Poll: Where do you live? by binarynate on Friday February 04, 2022 @07:23PM (#30215560)
Good idea—I just added a percentage column, as well as a row at the bottom for the total count
Re:Poll: Where do you live? by gabrielsroka on Friday February 04, 2022 @04:45PM (#30213747)
Re:Poll: Where do you live? by newaccount74 on Friday February 04, 2022 @06:25PM (#30214961)
Oh, I need to type Object.entries(x) instead of x.entries()

Makes sense, otherwise entries would contain itself.

Thank you!

Re:Poll: Where do you live? by eyelidlessness on Friday February 04, 2022 @09:10PM (#30216349)
Entries only iterates enumerable items (unless you make something evil). None of the native types with entries in their prototype iterate over that method
Re:Poll: Where do you live? by shafkathullah on Saturday February 05, 2022 @01:48AM (#30218492)
Just click on 'Value' in console to sort by value