If you look at the specifications you will see that the output range for the GP2Y0A02 is about 0.5V to 2.75V. With a 5V analog input that's about 102 to 563. You might want to constrain the inputs before mapping:
int irVal = analogRead(irSensor);
int irMapVal = map(constrain(irVal,102,563), 102, 563, 0, 100);
Thanks very much, thats perfect
If you don't mind me asking, how did you work out the 102 to 563 range with the incoming and outgoing voltages? I know the Arduino Uno ADC is 10bit (0, 1024). Did you multiply the 0.5 and 2.75 by something?