Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 581 Bytes

is_it_even.md

File metadata and controls

25 lines (19 loc) · 581 Bytes

Description

In this Kata we are passing a number (n) into a function.

Your code will determine if the number passed is even (or not).

The function needs to return either a true or false.

Numbers may be positive or negative, integers or floats.

Floats with decimal part non equal to zero are considered UNeven for this kata.

My Solution

def test_even(n)
  n == n.to_i ? n.to_i.even? : false
end

Better/Alternative solution from Codewars

def test_even(n)
  n % 2 == 0
end