def is_even(number):
return number % 2 == 0
# Example usage:
print(is_even(4)) # Output: True
print(is_even(7)) # Output: False
function isEven(number) {
return number % 2 === 0;
}
// Example usage:
console.log(isEven(4)); // Output: true
console.log(isEven(7)); // Output: false
The Python implementation uses a function named is_even
that takes a single argument number
. It returns True
if the number is even (i.e., when the remainder of the division of the number by 2 is zero), otherwise, it returns False
.
The JavaScript implementation uses a function named isEven
that also takes a single argument number
. It returns true
if the number is even (using the same logic as the Python function) and false
otherwise.
def
keyword, whereas in JavaScript, the function
keyword is used.True
and False
for boolean values, while JavaScript uses true
and false
.print()
, while JavaScript uses console.log()
.