js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Naughty or Nice? #503

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/52a6b34e43c2484ac10000cd/train/javascript

RazvanBugoi commented 4 years ago
function getNiceNames(people){
  let obj = people.filter((el,index) => people[index]['wasNice'] == true);
  let output = [];
   if (obj.length > 0) {
      for (let i=0; i<obj.length; i++){
        output.push(obj[i]['name']);
    }
  }
    return output;
};

function getNaughtyNames(people){
    let obj = people.filter((el,index) => people[index]['wasNice'] == false);
  let output = [];
   if (obj.length > 0) {
      for (let i=0; i<obj.length; i++){
        output.push(obj[i]['name']);
    }
  }
    return output;
}