<<<<<<< HEAD Code Wars - Brett Crafton

Find the Remainder

Question

Write a function that accepts two integers and returns the remainder of dividing the larger value by the smaller value. Division by zero should return NaN. Examples:

n = 17 m = 5 result = 2 (remainder of `17 / 5`) n = 13 m = 72 result = 7 (remainder of `72 / 13`) n = 0 m = -1 result = 0 (remainder of `0 / -1`) n = 0 m = 1 result - division by zero

Solution by -

My Solution


	function remainder(n, m){
		if( n == 0 && n < m){
			return NaN
		}
		else if( m == 0 && m < n){
			return NaN
		}
		else{
			return n > m ? n % m : m % n
		}
	}
				

Try it yourself - CodeWars

======= Code Wars - Brett Crafton

Find the Remainder

Question

Write a function that accepts two integers and returns the remainder of dividing the larger value by the smaller value. Division by zero should return NaN. Examples:

n = 17 m = 5 result = 2 (remainder of `17 / 5`) n = 13 m = 72 result = 7 (remainder of `72 / 13`) n = 0 m = -1 result = 0 (remainder of `0 / -1`) n = 0 m = 1 result - division by zero

Solution by -

My Solution


	function remainder(n, m){
		if( n == 0 && n < m){
			return NaN
		}
		else if( m == 0 && m < n){
			return NaN
		}
		else{
			return n > m ? n % m : m % n
		}
	}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39