20 lines
		
	
	
		
			511 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
		
		
			
		
	
	
			20 lines
		
	
	
		
			511 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
|   | --- | ||
|  | title: Finding a Remainder in JavaScript | ||
|  | --- | ||
|  | The _remainder operator_ `%` gives the remainder of the division of two numbers. | ||
|  | 
 | ||
|  | ## Example
 | ||
|  | 
 | ||
|  |     5 % 2 = 1 because | ||
|  |     Math.floor(5 / 2) = 2 (Quotient) | ||
|  |     2 * 2 = 4 | ||
|  |     5 - 4 = 1 (Remainder) | ||
|  | 
 | ||
|  | ## Usage
 | ||
|  | 
 | ||
|  | In mathematics, a number can be checked even or odd by checking the remainder of the division of the number by 2. | ||
|  | 
 | ||
|  |     17 % 2 = 1 (17 is Odd) | ||
|  |     48 % 2 = 0 (48 is Even) | ||
|  | 
 | ||
|  | **Note** Do not confuse it with _modulus_ `%` does not work well with negative numbers. |