js-mentorship-razvan / javascript

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

Check same case #601

Closed RazvanBugoi closed 2 years ago

RazvanBugoi commented 2 years ago

https://www.codewars.com/kata/5dd462a573ee6d0014ce715b/train/javascript

RazvanBugoi commented 2 years ago
function sameCase(a, b){
  if (!a.match(/[a-zA-Z]/g) || !b.match(/[a-zA-Z]/g)) { return -1 }
  return a == a.toLowerCase() && b == b.toLowerCase() || a == a.toUpperCase() && b == b.toUpperCase() ? 1 : 0
}