Skip to content

Instantly share code, notes, and snippets.

@natafaye
Created March 17, 2022 03:35
Show Gist options
  • Save natafaye/3492017f305eec1c152858e1ae60521c to your computer and use it in GitHub Desktop.
Save natafaye/3492017f305eec1c152858e1ae60521c to your computer and use it in GitHub Desktop.
function countDevelopers(list) {
return list.filter( d => d.continent === "Europe" && d.language === "JavaScript" ).length;
}
// OLD VERSION 3
function countDevelopersOld3(list) {
return list.filter( developer => developer.continent === "Europe" && developer.language === "JavaScript" ).length;
}
// OLD VERSION 2
function countDevelopersOld2(list) {
const europeanJS = list.filter( developer => developer.continent === "Europe" && developer.language === "JavaScript" )
return europeanJS.length;
}
// OLD VERSION
function countDevelopersOld(list) {
let count = 0;
for(const developer of list) {
// if the developer is from Europe and their language is javascript
if(developer.continent === "Europe" && developer.language === "JavaScript") {
// increment the count
count++;
}
}
return count;
}
function greetDevelopers(list) {
list.forEach(d => d.greeting = `Hi ${ d.firstName }, what do you like the most about ${ d.language }?` )
return list;
}
function isRubyComing(list) {
return list.some( developer => developer.language === "Ruby")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment