COLOR CONVERTER | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

COLOR CONVERTER

Can someone understand me the following code https://code.sololearn.com/WswGE9KP6QsU/?ref=app

9th Jul 2021, 7:29 PM
Little_Zabi
Little_Zabi - avatar
2 Answers
+ 1
It uses substring method to extract a string of 2 characters after every 2 index starting from index 0. Example, if hex value is "ec45f3" then (0,2) will give us a string of "ec", (2,4) will give us a string of "45" and (4, 6) => "f3". now it provides those substrings to parseInt method which tries to convert them into integer(which is what rgb presents) from hex values (indicated by base 16 passed as second argument to parseInt)
9th Jul 2021, 7:50 PM
Abhay
Abhay - avatar
0
Thanks i will try in a momment
9th Jul 2021, 7:52 PM
Little_Zabi
Little_Zabi - avatar