Check the given number is odd or even

Test cases:

Test cases Expected Result
testOddEven(12) even OK
testOddEven(3) odd OK
testOddEven(-55) odd OK

Java solution:

package test;

public class Program2 {
	public static void main(String[] args) {
	public static String testOddEven(int num){
		if (num % 2 == 0) {
			return "even";
		return "odd";

Javascript solution:

const testOddEven = (num) => {
    if (num % 2 === 0) {
        return 'even';
    return 'odd';

console.log(testOddEven(12)); //even
console.log(testOddEven(3)); //odd
console.log(testOddEven(-55)); //odd


About the author

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *