RGB to HEX

Convert an RGB color value to its hexadecimal string representation.

Asked in frontend interviews at Google, Amazon and Flipkart