Skip to content

Instantly share code, notes, and snippets.

@oguzgelal
Created July 13, 2021 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oguzgelal/8032e0b92077d4b2be909061d6182cdc to your computer and use it in GitHub Desktop.
Save oguzgelal/8032e0b92077d4b2be909061d6182cdc to your computer and use it in GitHub Desktop.
Code used to analyse StateOfJS2020 data
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))
@oguzgelal
Copy link
Author

Data:

https://www.kaggle.com/sachag/state-of-js

Output:

total 99715
aware_more_than_5 96.2
aware_more_than_10 93.05
aware_more_than_20 50.71
interested_more_than_5 91.74
interested_more_than_10 63.93
interested_more_than_20 13.53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment