js-mentorship-razvan / javascript

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

Solve 'A wolf in sheep's clothing' #317

Closed odv closed 5 years ago

odv commented 5 years ago

https://www.codewars.com/kata/a-wolf-in-sheeps-clothing/train/javascript

RazvanBugoi commented 5 years ago
function warnTheSheep(queue) {
  if (queue[queue.length -1] === 'wolf') {
    return 'Pls go away and stop eating my sheep';
    } else {
     let index = queue.findIndex( (x) => x == 'wolf' );
     return `Oi! Sheep number ${queue.length - index - 1}! You are about to be eaten by a wolf!`;
    }
}