This react interview challenge was awesome to solve

  Рет қаралды 49,493

Web Dev Cody

Web Dev Cody

Жыл бұрын

💬 Discord / discord
🔔 Newsletter newsletter.webdevcody.com/
📁 GitHub github.com/webdevcody
📺 Twitch / webdevcody
🤖 Website webdevcody.com
🐦 Twitter / webdevcody

Пікірлер: 85
@alexliebhaber3109
@alexliebhaber3109 Жыл бұрын
I’ve been watching you for a month now, and I just wanted to say thank you for doing what you do. It helps a lot how you explain what you’re thinking while you’re problem solving.
@WebDevCody
@WebDevCody Жыл бұрын
I appreciate that!
@hassankamel755
@hassankamel755 Жыл бұрын
same
@Bukosaure
@Bukosaure Жыл бұрын
Love the way to verbalize your thought process and your humility. Keep it up Cody!
@germain1984
@germain1984 Жыл бұрын
please never stop making videos, they're all super insightful
@FuzzyAnkles
@FuzzyAnkles 9 ай бұрын
really great content Cody. keep on rockin! It really helps understand react just by doign this small challenges.
@Kxneki2433
@Kxneki2433 Жыл бұрын
I just wanted say thanks for this content, it would be really great if you keep on posting this challenges
@insensibility
@insensibility Жыл бұрын
I love the way you teach. I am an aspiring Front-End Developer and currently a first year Information Technology student. If it ever cross your mind to recreate you beginner to full-stack developer series that would be great! Keep up!
@DrifterXx22
@DrifterXx22 Жыл бұрын
The fact that you can bring a real world problem into code is quite amazing. This skill is what every programmer should have.
@aeoliun
@aeoliun Жыл бұрын
>The fact that you can bring a real world problem into code is quite amazing. This skill is what every programmer should have. I mean that's literally the definition of a software engineer's job. -_-
@TU7OV
@TU7OV 11 ай бұрын
@@aeoliun lmao
@rowsncols
@rowsncols 11 ай бұрын
@@aeoliun why did you quote him tho? the comment is above you
@ToddDunning
@ToddDunning Жыл бұрын
Fantastic work Cody, man that last part was gnarly, I would have mentally checked out.
@mavsocc
@mavsocc 2 ай бұрын
the best learning is by debuggin. the videos with live debagging are the most heplful ones. thanks very much.
@gyros9162
@gyros9162 10 ай бұрын
Thank you for this challenge! Taking this stuff with tills into React is great practice
@ardianhotii
@ardianhotii Жыл бұрын
I really like your videos, especially these challenges. Keep doing these videos more, it helps me and people so much
@christopherjschultz
@christopherjschultz Жыл бұрын
This is an awesome exercise! Thanks for sharing your solution, keep up the great work!
@TedMosby-fk5gj
@TedMosby-fk5gj 6 ай бұрын
Thank you for actually explaining the final product or what we need to do in the begenning. Some of your other code challenge videos I dont understand the problem or final result and end up not doing it. Great video.
@WebDevCody
@WebDevCody 6 ай бұрын
I’ll try to remember to do that in future videos, thanks for the feedbacl
@Pvillanueva13
@Pvillanueva13 Жыл бұрын
Appreciate the live problem solving sessions!
@thomasgold2022
@thomasgold2022 Жыл бұрын
love your content. I really enjoy the verbal thought process
@diemantrabeats7551
@diemantrabeats7551 Жыл бұрын
You have to set the input state to an empty string whenever you don’t want any value in it… also setting the input type to number doesn’t always prevent input of characters, they can type really fast and it can bug out, it’s better to do a second check and then convert the e.target.value to a number. There’s a Math.sign() that takes a string or a number and will return 1 for positive numbers, -1 for negative numbers, 0 for 0, -0 for -0, NaN for “foo”, 1 for “5”, and -1 for “-4”. Then you can do your if statements and set your state 😅
@WebDevCody
@WebDevCody Жыл бұрын
thanks for the info. My brain often goes blank when I do these live coding things
@Endrit719
@Endrit719 Жыл бұрын
@@WebDevCody I feel you, I am pro when I do it alone, I am pepega when someone is watching me
@annusingh4694
@annusingh4694 Жыл бұрын
Great content as always! Thank you so much
@eshw23
@eshw23 7 ай бұрын
These are great to do, I was able to do all of it except for the decrementing part, always good to fail and get a stronger grasp on these concepts
@stevencoy
@stevencoy Жыл бұрын
For someone learning React, this is extremely helpful.
@andrewwall2730
@andrewwall2730 6 ай бұрын
Great video and a fun challenge. Unless I missed something the only thing I would add is to clear the interval when all the lines are empty. Look forward to your next challenge. Also, can't you just put min="1' attribute on the input. Thank you for these challenges!
@user-cy6vu7gv8x
@user-cy6vu7gv8x Жыл бұрын
Very good problem and his solution, thank you so much for your content!
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 7 ай бұрын
love from India ❤very useful videos...keep on postingsuch React Coding challenges
@Mario-vq9ev
@Mario-vq9ev Жыл бұрын
More videos like this!! Love it 🎉😂❤
@jorgejorge08
@jorgejorge08 Жыл бұрын
Love it!!keep it up!
@exoderp3651
@exoderp3651 Жыл бұрын
Your videos are great for learning!! Problem solving is an essential skill and I love how you present these videos and explain your process. I learn a bunch of best practices and how I should break down problems in general. One thing is maybe include more descriptive titles and/or thumbnails? I would find it easier to find a problem I'd like to solve based off of descriptive titles or images instead of the generic ones. Just a suggestion. Keep up the great work!!
@exoderp3651
@exoderp3651 Жыл бұрын
To clarify, this only really applies to the interview challenges.
@WebDevCody
@WebDevCody Жыл бұрын
Yeah maybe a screenshot of what we will build
@lougieq1291
@lougieq1291 4 ай бұрын
The input error can be solved by parsing the value to int on your set state function like so: setItemsInPersonCart(parseInt(e.currentTarget.value)); It gave such error since by default the input value is string.
@FiorinaEU
@FiorinaEU 5 ай бұрын
There's really no need for a foreach-loop when you could just use the traditional for-loop. This would give you the index directly of the line containing the least amount. Set lines[idx] = [...lines[idx], itemsInPersonCart] and then use this in the setState through setLines([...lines]). Simpler, faster and way easier to read. Otherwise, good challenge. I liked it and I raced you ;)
@anthonygg_
@anthonygg_ Жыл бұрын
Love this!
@kushalkamra3803
@kushalkamra3803 Жыл бұрын
Thank you 🙏
@reydez84
@reydez84 Жыл бұрын
damn this is great practice, i watched it without code following but ima watch it again and gonna bust out my visual studio code
@RicardoGerbaudo
@RicardoGerbaudo 7 ай бұрын
great video! which vscode theme are you using?
@raymondmichael4987
@raymondmichael4987 Жыл бұрын
Thanks, learned a thing or two
@SeibertSwirl
@SeibertSwirl Жыл бұрын
Good job babe!!!
@TheDenga147
@TheDenga147 Жыл бұрын
I love yout videos! Quick question, what shortcut did you use at 9:52 to change all the variable names instead of the word itself??
@bobbyboxer2664
@bobbyboxer2664 Жыл бұрын
F2
@haipengwu2649
@haipengwu2649 11 ай бұрын
I think there might be a bug in this code. When adding to the new line, when there are more than one line that has the same amount of items in it on, it seems like the logic of line === lineWithLeast? [...line, itemsInPersonCart]:line will end up updating all of them, please let me know if that is the case? thank you
7 ай бұрын
I check this. There is no bug. Works fine. example. const ar=[1]; const arr=[1]; console.log(ar === arr); // Expected output: false console.log(ar === ar); // Expected output: true
Жыл бұрын
I would rate this solution 6/10
@TheSourLemonz
@TheSourLemonz Жыл бұрын
ur awesome to solve
@matttaydavis
@matttaydavis 11 ай бұрын
I like tackling these then comparing your methods vs mine to see where I can improve. It would be cool if you also gave an idea of how long you think it would take a beginner to tackle the problem, so I know just how inefficient my times are.
@user-zv6bv7eu8k
@user-zv6bv7eu8k 7 ай бұрын
9 hours
@iamvitalya
@iamvitalya Жыл бұрын
could you tell, please, what VS Code color theme is it?
@sean_haz
@sean_haz 9 ай бұрын
What is your keyboard setup? Seems likeyou transition from keyboard to mouse instantly, what are you using for cursor control?
@WebDevCody
@WebDevCody 9 ай бұрын
I use my trackpad
@frankkim9178
@frankkim9178 Жыл бұрын
What’s the name of the extension that gives you the error messages next to your code?
@WebDevCody
@WebDevCody Жыл бұрын
Error lens
@ricko13
@ricko13 Жыл бұрын
hey Cody why you using *e.currentTarget* instead of *e.target* ?
@WebDevCody
@WebDevCody Жыл бұрын
currentTarget is the actual dom element that the event listener is attached to. target is the thing that triggered the click event (which might not be the actual button clicked but instead maybe an icon inside the button)
@bobbyboxer2664
@bobbyboxer2664 Жыл бұрын
Does anyone know what theme he’s using?
@ZantierTasa
@ZantierTasa Жыл бұрын
react just doesn't seem to like value={undefined} Keeping the rest of your code the same, this fixes the error: value={itemsInPersonCart === undefined ? "" : itemsInPersonCart} (or you can use useState, rather than using undefined)
@notfadeaway6617
@notfadeaway6617 10 ай бұрын
nice video. didn't understand why you have to setItemsinPersonCart(undefined) when "", could't you just pass it?
@ghury1
@ghury1 Жыл бұрын
hi, which vs code are you using?
@WebDevCody
@WebDevCody Жыл бұрын
bearded theme stained blue
@Zechey
@Zechey Жыл бұрын
Been working on this today, it seemed simple at first but setIntervals turned out to be pretty tricky to work with in React!
@apaksimen
@apaksimen 9 ай бұрын
how do you rename on 9:57, what shortcut you've used?
@apaksimen
@apaksimen 9 ай бұрын
found it myself: on Mac "fn + F2"
@WebDevCody
@WebDevCody 9 ай бұрын
Probably f2
@kklowd
@kklowd Жыл бұрын
I didn't really understand the timing process. I would have created an interval for each line since that's how a line would process practically. this was a cool problem though
@WebDevCody
@WebDevCody Жыл бұрын
yeah that would be interesting as well, each queue has their own interval because some cashiers are faster than others.
@dr_davinci
@dr_davinci Жыл бұрын
@@WebDevCody that sounds pretty interesting, I might give it a try :)
@loatedits659
@loatedits659 Жыл бұрын
Vs code theme name
@chrisstucker1813
@chrisstucker1813 7 ай бұрын
My solution to this was awful lmao
@lougieq1291
@lougieq1291 4 ай бұрын
For the addPersonToLine function, I think instead of using map with the setLines method you can probably just use the spread operator like lines[lineWithLeast].push(itemsInPersonCart); setLines([...lines]);
@yevhentarik4551
@yevhentarik4551 Жыл бұрын
I don’t get in what real life problem I can use this approach… I mean it would be nice to have examples that actually deals with real dev problems not some general examples) cause as I understand your timer represents cashier work in this example
@WebDevCody
@WebDevCody Жыл бұрын
The point is to stress your problem solving abilities
@GitIsBeautiful
@GitIsBeautiful Жыл бұрын
It is 😄 set the state to 0.
@thesnarbo2814
@thesnarbo2814 Жыл бұрын
why not just set min="1" on the input so you wont get negative or an undefined number? no need for JS here
@samjohnston3416
@samjohnston3416 Жыл бұрын
Some more challenging ideas: - Each queue has its own interval using something like Math.random - Add or remove checkouts using buttons - Dynamically add or remove checkouts based if the line has more than 3 people waiting or total number of items exceeds 20 (in real world you would also have a limited number of checkouts and or staff) - Store checkouts stored in a key value pair object such as Maps
@WebDevCody
@WebDevCody Жыл бұрын
good suggestions!
@casull6447
@casull6447 Жыл бұрын
I just disabled the button like this ->
Can you solve this beginner React interview practice problem?
22:03
Web Dev Cody
Рет қаралды 112 М.
DELETE TOXICITY = 5 LEGENDARY STARR DROPS!
02:20
Brawl Stars
Рет қаралды 20 МЛН
小女孩把路人当成离世的妈妈,太感人了.#short #angel #clown
00:53
1 класс vs 11 класс  (игрушка)
00:30
БЕРТ
Рет қаралды 3,9 МЛН
The New JS Features Coming Soon (I'm so hyped)
39:03
Theo - t3․gg
Рет қаралды 81 М.
This is a good beginner React interview challenge question
30:38
Web Dev Cody
Рет қаралды 71 М.
React Coding Interview Ft. Clément Mihailescu
47:08
Conner Ardman
Рет қаралды 120 М.
Mock Technical Interview - Javascript Developer Junior Level
1:46:35
Tech with Nader
Рет қаралды 30 М.
REAL React Interview Questions - Live Coding
13:03
Peter Elbaum
Рет қаралды 65 М.
I loved solving this junior react interview challenge
26:02
Web Dev Cody
Рет қаралды 151 М.
This is a good intermediate react interview challenge
38:30
Web Dev Cody
Рет қаралды 52 М.
How to NOT Fail a Technical Interview
8:26
Fireship
Рет қаралды 1,3 МЛН
Here is a more challenging react interview exercise
33:24
Web Dev Cody
Рет қаралды 38 М.
DELETE TOXICITY = 5 LEGENDARY STARR DROPS!
02:20
Brawl Stars
Рет қаралды 20 МЛН