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) {
		Program2.testOddEven(12);
		Program2.testOddEven(3);
		Program2.testOddEven(-55);
	}
	
	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

 

Partners: bedste udenlandske casinoer casinoer uden dansk licens funky time tracksino casinos ohne lizenz betrugstest pikakasinot ベスト astropay カジノ come giocare al crazy time giochi vlt novomatic book of ra libro Casino Mega

Bushan Sirgur

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

Leave a Reply