Тёмный

JS Interview - Random Hex Colours - Question 10 

Steve Griffith - Prof3ssorSt3v3
Подписаться 100 тыс.
Просмотров 4,7 тыс.
50% 1

This episode talks about the most efficient way to generate a random hex colour that will always be exactly 6 digits.
Full Interview Question Playlist: • JS Interview - Timeout...
Starter Code GIST: gist.github.com/prof3ssorSt3v...

Опубликовано:

 

29 июн 2019

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 23   
@srinivasaraoyp3640
@srinivasaraoyp3640 Год назад
I always look for your video demos. Thank you.
@wyattlastname477
@wyattlastname477 5 лет назад
Dude you videos are so cool. Like, quick and to the point. Even in the basic ones I learn something new and I've been doing all of this for a while. Well done, please never stop making JS videos haha.
@PSProduktions
@PSProduktions Год назад
Thank you sooo much! I found some solution on stack overflow before this but all that base number 10 16 talk was confusing me. After watching your video I am no longer confused. Thanks for explaining the solution to the problem and the base numbers thing so nicely!
@jasco1004
@jasco1004 5 лет назад
Really, thanks a lot for these topics. It helps me a lot.
@iamwhatiam1221
@iamwhatiam1221 5 лет назад
hello sir long time...... and i knew this one.. but i keep an eye out always for your methods.... this was so compact and to the mark.....:)
@rameshkumarveldurai5241
@rameshkumarveldurai5241 2 года назад
Nice! Thank you :)
@fromspacebackgrounds
@fromspacebackgrounds 3 года назад
Thank you this is so helpful!
@barungh
@barungh 5 лет назад
Nice 1👍
@srinath7318
@srinath7318 2 года назад
Thank you so much,
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 2 года назад
Welcome 😊
@ck0024
@ck0024 5 лет назад
*Cool* 👍
@kanugantikarthikredd
@kanugantikarthikredd 4 года назад
Hi, thanks for another great explanation! Wouldn't this function exclude the hex values of pure white and black?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
We are just taking the first 6 digits of the random value. Those could be FFFFFF or 000000.
@samuelmatheson9655
@samuelmatheson9655 5 лет назад
Yay I already knew something
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 5 лет назад
The list of things you know grows every day.
@rorothegoatboat
@rorothegoatboat 2 года назад
create 1,000 shapes and make a certain percentage a specific colour.
@yagami-light
@yagami-light 3 года назад
function generateRandomColorHex() { return `#${Math.floor(Math.random() * 16777215).toString(16)}`; } for those who wonder what's 16777215 - it's evaluated value of (256 ^ 3) - 1, meaning 0-255 for each channel r, g, b
@yagami-light
@yagami-light 3 года назад
For Didactic purposes: function generate() { const red = Math.floor(Math.random() * 256).toString(16); const green = Math.floor(Math.random() * 256).toString(16); const blue = Math.floor(Math.random() * 256).toString(16); return `#${red + green + blue}`; } but it makes no sense to do this way, just for the sole purpose of understanding what's going on step by step. otherwise this is repetitive code which breaks DRY (Don't Repeat Yourself) Principles
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 года назад
The problem with that solution is that you get a number that can be any number of digits between 1 and 6. For CSS you must have 3, 6 or 8 digits, most commonly 6.
@yagami-light
@yagami-light 3 года назад
@@SteveGriffith-Prof3ssorSt3v3 Indeed, but I do not know any other ways than you showed in tutorial to fix this problem
Далее
JS Interview - parseInt and map - Question 11
5:45
Просмотров 6 тыс.
TYLA DANCE TREND😭 | #shorts #emilydobson
00:12
Просмотров 2,7 млн
Random Color Generator | JavaScript Tutorial
12:00
Просмотров 1,5 тыс.
How Do HEX Color Codes Work? (in 60 seconds)
1:00
Просмотров 158 тыс.
Chrome Dev Tools Source Panel and Breakpoints
18:21
Просмотров 5 тыс.
Random Color Generator Using JavaScript
5:09
Просмотров 37 тыс.
Checking for the Existence of JavaScript Variables
9:08
Chrome Dev Tools Debugging CSS
16:18
Просмотров 8 тыс.
Important differences between textContent and innerText
11:44