Count Number of animals in a zoo from given number of head and legs | Function that calculates Rabbits ; Driver code
function countRabbits ( Heads , Legs ) { var count = 0 ; count = ( Legs ) - 2 * ( Heads ) ; count = count / 2 ; return count ; } var Heads = 100 , Legs = 300 ; var Rabbits = countRabbits ( Heads , Legs ) ; document . write ( " " + Rabbits + " " ) ; document . write ( " " + ( Heads - Rabbits ) ) ;