Coding Meetup Flashcards
Count the number of JavaScript developers coming from Europe
var list1 = [ { firstName: 'Noah', lastName: 'M.', country: 'Switzerland', continent: 'Europe', age: 19, language: 'JavaScript' }, { firstName: 'Maia', lastName: 'S.', country: 'Tahiti', continent: 'Oceania', age: 28, language: 'JavaScript' }, { firstName: 'Shufen', lastName: 'L.', country: 'Taiwan', continent: 'Asia', age: 35, language: 'HTML' }, { firstName: 'Sumayah', lastName: 'M.', country: 'Tajikistan', continent: 'Asia', age: 30, language: 'CSS' } ];
function countDevelopers(list) { // your awesome code here :) }
//filter arr //return length of arr
return list .filter(dev=> dev.continent === 'Europe' && dev.language === 'JavaScript' ) .length
Greet developers
Return an array where each object will have a new property ‘greeting’ with the following string value:
Hi < firstName here >, what do you like the most about < language here >?
var list1 = [ { firstName: 'Sofia', lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java' }, { firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: 'Python' }, { firstName: 'Madison', lastName: 'U.', country: 'United States', continent: 'Americas', age: 32, language: 'Ruby' } ];
[{ firstName: ‘Sofia’, lastName: ‘I.’, country: ‘Argentina’, continent: ‘Americas’, age: 35, language: ‘Java’,
greeting: ‘Hi Sofia, what do you like the most about Java?’ …]
function greetDevelopers(list) { // thank you for checking out my kata :) }
// forEach to add anew key:value pair. //return modified list
list.forEach(dev => {
dev.greeting = Hi ${dev.firstName},what do you like the most about ${dev.language}?
})
return list;
Is Ruby coming?
Your task is to return:
true if at least one Ruby developer has signed up; or
false if there will be no Ruby developers.
var list1 = [ { firstName: 'Emma', lastName: 'Z.', country: 'Netherlands', continent: 'Europe', age: 29, language: 'Ruby' }, { firstName: 'Piotr', lastName: 'B.', country: 'Poland', continent: 'Europe', age: 128, language: 'Javascript' }, { firstName: 'Jayden', lastName: 'P.', country: 'Jamaica', continent: 'Americas', age: 42, language: 'JavaScript' } ];
function isRubyComing(list) { // thank you for checking out my kata :) }
return list.some(dev=>dev.language === ‘Ruby’);
Find the first Python developer
Your task is to return one of the following strings:
< firstName here >, < country here > of the first Python developer who has signed up;
or
There will be no Python developers if no Python developer has signed up.
var list1 = [ { firstName: 'Mark', lastName: 'G.', country: 'Scotland', continent: 'Europe', age: 22, language: 'JavaScript' }, { firstName: 'Victoria', lastName: 'T.', country: 'Puerto Rico', continent: 'Americas', age: 30, language: 'Python' }, { firstName: 'Emma', lastName: 'B.', country: 'Norway', continent: 'Europe', age: 19, language: 'Clojure' } ];
function getFirstPython(list) { // Thank you for checking out my kata :) }
//new variable value of list.find //return if new variable is not undefined return firstname and counter else return "There will be no Python developers"
let dev=list.find(dev=>dev.language === 'Python'); return dev !== undefined ? `${dev.firstName}, ${dev.country}` :'There will be no Python developers'
Can they code in the same language?
Your task is to return either:
true if all developers in the list code in the same language;
or
false otherwise.
var list1 = [ { firstName: 'Daniel', lastName: 'J.', country: 'Aruba', continent: 'Americas', age: 42, language: 'JavaScript' }, { firstName: 'Kseniya', lastName: 'T.', country: 'Belarus', continent: 'Europe', age: 22, language: 'JavaScript' }, { firstName: 'Hanna', lastName: 'L.', country: 'Hungary', continent: 'Europe', age: 65, language: 'JavaScript' }, ];
function getAverageAge(list) {
}
// list.every using list[0] as comparison.
return list.every(dev=>dev.language === list[0][‘language’] );
//for every developer in the list //