You need Login/Signup to run/submit the code.
How to convert RGB to HEX? JavaScript Interview Question | Frontend Problem Solving
@Devtools Tech
In this question, you need to create a function rgbToHex
that converts RGB
format to HEX
format.
Syntax
/**
* @param {string}
* @param {string}
* @param {string}
* @returns {string}
*/
rgbToHex(r, g, b) { ... }
Parameters
All parameters are mandatory.
r
: stringg
: stringb
: string
Return
The HEX value as an uppercased string.
rgbToHex(255, 255, 255);
// -> Should return #FFFFFF
rgbToHex(0, 0, 0);
// -> Should return #000000
rgbToHex(186, 218, 85);
// -> Should return #BADA55
rgbToHex(256, 255, 255);
// -> Should return #FFFFFF
Submission
Please start the timer before starting and finish your solution within 45 mins. Share your solution with us on Twitter or LinkedIn.
Please check Author Remarks Section
for our solution and more questions.