May 25 Codewar
I tried something new today. I followed along a streamer who was going through codewars. She did two that I had already and done and failed. It was nice to listen to someone else go through them and give their thoughts on it. Totally solved it very different from what I thought initially. I unfortunately did no save my attempt. I will just show how she showed us.
The first one we tried was to return human years, cat, and dog years. The first year both are 15, the second year is 9 years+ for dogs and cats. Every year after that you multiple 4 for the cats and 5 for dogs. She walked us through using a ternary operation. I liked it because I got to practice it a little more.
var humanYearsCatYearsDogYears = function(humanYears) {
// Your code here!
return [humanYears, (15 + ((humanYears >2)? (9+(humanYears-2)*4) : humanYears == 2 ? 9: 0)), (15 + ((humanYears >2)? (9+(humanYears-2)*5) : humanYears == 2 ? 9: 0))];
}
I tried this codewar since I needed to think about something else other than the news at this moment.