Created
July 13, 2021 19:54
-
-
Save oguzgelal/8032e0b92077d4b2be909061d6182cdc to your computer and use it in GitHub Desktop.
Code used to analyse StateOfJS2020 data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const participants = require("./data.json"); | |
const isAware = (experience) => experience !== "never_heard"; | |
const isInterested = (experience) => | |
experience === "interested" || experience === "would_use"; | |
const numParticipantsMoreThan = (dictNumTechToNumParticipants, num) => Object | |
.keys(dictNumTechToNumParticipants) | |
.filter(n => n > num) | |
.reduce((acc, n) => acc + dictNumTechToNumParticipants[n], 0) | |
const percent = (num) => Math.round(num * 10000) / 100 | |
const { aware, interested } = participants.reduce((acc, participant) => { | |
const { aware = {}, interested = {} } = acc; | |
const experiences = !participant.tools | |
? [] | |
: Object.values(participant.tools).map((tool) => tool.experience); | |
const numAware = experiences.filter(isAware).length; | |
const numInterested = experiences.filter(isInterested).length; | |
if (!aware[numAware]) aware[numAware] = 0; | |
if (!interested[numInterested]) interested[numInterested] = 0; | |
aware[numAware] = (aware[numAware] || 0) + 1; | |
interested[numInterested] = (interested[numInterested] || 0) + 1; | |
return { | |
aware, | |
interested, | |
}; | |
}, {}); | |
const totalParticipants = participants.length | |
const totalAwareOfMoreThan5 = numParticipantsMoreThan(aware, 5) | |
const totalAwareOfMoreThan10 = numParticipantsMoreThan(aware, 10) | |
const totalAwareOfMoreThan20 = numParticipantsMoreThan(aware, 20) | |
const totalInterestedInMoreThan5 = numParticipantsMoreThan(interested, 5) | |
const totalInterestedInMoreThan10 = numParticipantsMoreThan(interested, 10) | |
const totalInterestedInMoreThan20 = numParticipantsMoreThan(interested, 20) | |
console.log('total', totalParticipants) | |
console.log('aware_more_than_5', percent(totalAwareOfMoreThan5 / totalParticipants)) | |
console.log('aware_more_than_10', percent(totalAwareOfMoreThan10 / totalParticipants)) | |
console.log('aware_more_than_20', percent(totalAwareOfMoreThan20 / totalParticipants)) | |
console.log('interested_more_than_5', percent(totalInterestedInMoreThan5 / totalParticipants)) | |
console.log('interested_more_than_10', percent(totalInterestedInMoreThan10 / totalParticipants)) | |
console.log('interested_more_than_20', percent(totalInterestedInMoreThan20 / totalParticipants)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Data:
Output: