본문 바로가기
알고리즘/Codewars

[Codewars] Opposites Attract (8 kyu) / JavaScript

by fluss 2023. 1. 12.

https://www.codewars.com/kata/555086d53eac039a2a000083

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Timmy & Sarah think they are in love, but around where they live, they will only know once they pick a flower each. If one of the flowers has an even number of petals and the other has an odd number of petals it means they are in love.

Write a function that will take the number of petals of each flower and return true if they are in love and false if they aren't.

 

코드

function lovefunc(flower1, flower2){
  return flower1 % 2 !== flower2 % 2;
}

댓글