This is a good intermediate react interview challenge

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น • 91

  • @luisguilhermesiqueiralinsd9199
    @luisguilhermesiqueiralinsd9199 2 ปีที่แล้ว +40

    Bro a 38 min that feels like 15 min, you explain so well. Good job :D

  • @ikarosouza
    @ikarosouza 2 ปีที่แล้ว +52

    The input has an inputMode prop that you can set to numeric, this will avoid those arrows that show up on inputs where the type is set to number and you'll still only be able to enter numbers in the input.

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +4

      awesome thanks for that info!

    • @grenadier4702
      @grenadier4702 ปีที่แล้ว +1

      Sadly, we hav Explorer 2.0, *cough* safari *cough* that doesn't suppoert that

  • @velifurkanturkoglu1387
    @velifurkanturkoglu1387 2 ปีที่แล้ว +6

    Hello! I am truly grateful for these videos. I have had finished the odin project but had been scared to apply for jobs, your channel and you really help me get through that fear. Keep these challenges coming!!!

    • @velifurkanturkoglu1387
      @velifurkanturkoglu1387 2 ปีที่แล้ว +2

      Also I must say that to whoever might read these, If you are someone who is bored at watching videos that teach "useState in React" kind of videos, watching this channel and experiencing his thought process will help you better than watching countless udemy courses. You are so through and to the point and this 40 mins of video basically feels 10 mins!

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      Thanks for watching, I’m glad you enjoy my content!

    • @buraksurumcuoglu8303
      @buraksurumcuoglu8303 2 ปีที่แล้ว

      @@WebDevCody You're also my favorite React content creator lately, by a long shot. I love watching the live coding/refactoring and the thought process is just pure guidance for us juniors. Keep up the good work Cody, thanks a lot!

  • @pongopeter8267
    @pongopeter8267 3 หลายเดือนก่อน

    Great video, I wasn't aware the debugger keyword existed, that will come in handy. The proxy trick was also really cool I'll have to keep that in mind if I ever need it.

  • @discoRyne
    @discoRyne 2 ปีที่แล้ว +2

    Good stuff and thanks for including the "behind the scenes" troubleshooting of the API.

  • @barssavas9938
    @barssavas9938 ปีที่แล้ว +2

    Those kinds of videos are awesome. They are literally better than clone projects. Because we can understand the basics of .tsx, and gives us a better understanding when we are using real-life scenarios or side projects. I hope you keep doing interview content

  • @集中-l7m
    @集中-l7m ปีที่แล้ว +1

    your live coding is like watching short detective story and good for quick lunch

  • @filipkrawczyk9630
    @filipkrawczyk9630 ปีที่แล้ว +2

    I think the way you wrote the setGridValue function is incorrect, because you are actually mutating the state directly. For example:
    const x = [[1,2],[3,4]];
    const y = [...x];
    y[0][0]=5;
    console.log(x[0][0]);
    prints 5 insted of 1. This is because 2d array is array of refrences to arrays, so by doing [...x], you just copy only references to those nested arrays but not arrays themselves. I think what you need to do is:
    const x = [[1,2],[3,4]];
    const y = x.map(a => [...a]);
    y[0][0]=5;
    console.log(x[0][0]);
    Mutating state like you did can lead to very hard to detect bugs.
    Am I right or am I missing something?

    • @WebDevCody
      @WebDevCody  ปีที่แล้ว +1

      Sounds accurate. It’s probably better to make sure I do a full copy of the nested arrays

  • @hemanthkotagiri8865
    @hemanthkotagiri8865 2 ปีที่แล้ว +4

    There we go! Thanks for hearing me out! Advanced next, please!

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      I’ll try to think of a more advanced challenge.

    • @tomiis4
      @tomiis4 2 ปีที่แล้ว

      @@WebDevCody I'm not sure how advanced it is. But I think it will be good to see some sorting or path finding algorithm visualizer.

    • @maharta8458
      @maharta8458 2 ปีที่แล้ว

      @@tomiis4 jesus, i'm a cs student and i will never be able to do that on my own

  • @IgnitedIce81
    @IgnitedIce81 2 ปีที่แล้ว +1

    Never knew about the `new Array` method, and never used the debugger (which is a shame, and I should learn it).
    And the proxy thing, that's extremely helpful.
    Learnt so much in 40 min, your videos are definitely worth the time, Thanks :)

  • @anshulyadav269
    @anshulyadav269 8 หลายเดือนก่อน

    nice I learnt a lot, you are my new fav list channel

    • @WebDevCody
      @WebDevCody  8 หลายเดือนก่อน

      Thanks man!

  • @Kay8B
    @Kay8B 2 ปีที่แล้ว

    This was cool and well explained. Honestly, AdventOfCode is also a really good practice for interview question and its a fun way to mix coding and the festive month. In my experience interviewers fail to give you practical examples like you've shown and still give these hardly ever used algorithm type questions.

  • @sid6576
    @sid6576 ปีที่แล้ว

    Binging these videos for an upcoming full-stack interview, solid work man

    • @imaginaryworld599
      @imaginaryworld599 ปีที่แล้ว

      how did the interview went?

    • @sid6576
      @sid6576 ปีที่แล้ว

      @@imaginaryworld599 Rejected

    • @PsychoDude
      @PsychoDude ปีที่แล้ว

      Did u get a job until now?

    • @sid6576
      @sid6576 ปีที่แล้ว

      yes@@PsychoDude

  • @benitso
    @benitso 2 ปีที่แล้ว

    Enjoying these vids, subscribed for sure!

  • @universecode1101
    @universecode1101 2 ปีที่แล้ว +4

    COOL project, very useful for improving in many things. I'm a React developer too

  • @briannhb
    @briannhb 2 ปีที่แล้ว +10

    You teach not only about the sudoku but also teach us how to use proxy 😃

    • @mostafabazyar4483
      @mostafabazyar4483 2 ปีที่แล้ว

      gods know how meny years i had this cors problem

  • @irtazahussain8118
    @irtazahussain8118 2 ปีที่แล้ว +2

    Can you please implement drag and drop inside a grid in react project? And make sure the scrolling behavior remains same on every screen.

  • @thomashoenselaars920
    @thomashoenselaars920 2 ปีที่แล้ว +1

    Nice video with some cool concepts! Though, is it me or is your UI rendering the rows as columns? At 16:23 in the vid you are editing UI row 1, cell 6, but in your data model its updating row 5 cell 1? And isnt that the reason you lateron have to swap the rowIndex and colIndex?

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      Yeah something is a bit backwards

  • @Ebiko
    @Ebiko 2 ปีที่แล้ว +1

    i am coding my own sudoku currently over on github ( github -> bloodiko -> sudoku (also on github pages))
    a good solution for the spacing issue of the grid is to use "repeat(9, min-content)" making it possible to even dynamically adjust cells based on screen hight later on.
    (but overall my sudoku is not that advanced yet, and my code probably massivly overcomplicated, but i tried what i can do.)
    Also: Keep in mind that spread (...) will only apply to the outer array (row). not the inner array(col/cell) this makes it not totally new, but just partially new with cols/cells still beeing references.

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว

      that's good info, css is my weakest skill, so there is a lot of I forget exists when doing flex box and grid layouts. Yeah the ... will remain the same references to all the elements, but provide you a new array reference, which is fine in this case. I just wanted to tell react to re-render, and providing it a 100% brand new array is not necessary to achieve that.

    • @Ebiko
      @Ebiko 2 ปีที่แล้ว

      @@WebDevCody true
      I needed it in some cases, that's why I mentioned it.
      Also I didn't know this min-content css stuff myself, my brother showed me, and helped me there with my project which was cool.

  • @internetaap
    @internetaap 2 ปีที่แล้ว

    This is awesome! I was just doing a project with a grid

  • @bsw4245
    @bsw4245 2 ปีที่แล้ว

    gotta say this is my favorite react contents

  • @centravanti9
    @centravanti9 11 หลายเดือนก่อน

    Nice content! Looking at the response, wouldn't it simpler to use 1 dimensional array? 🤔

  • @alasassi960
    @alasassi960 2 ปีที่แล้ว

    can someone tell me how to make shorts where I can show my browser and code in the same time I find it really very difficult

  • @Immacio
    @Immacio 2 ปีที่แล้ว

    I've been practicing and watching these react interview questions for a while now, incase I want to make a switch to a new company/job. However, I'm coming to realise there are quite a few companies out there who don't even test you on React at all. Even for a front-end engineer role, topics on system design, Leetcode (med to hard) and maybe a basic front-end test in vanilla JS are most likely to come up. I know this is more prevalent in FAANG companies, but could you share more insight on this topic? Are newer more modern small/mid sized companies still following this practice?
    From what I've heard from my senior engineers, there are definitely still some companies out there who don't test you on JS frameworks and assume from your knowledge of DSA and vanilla JS you are competent enough to pick up any JS framework.

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว

      That is probably true. I haven’t done real interviews for react positions in a while so idk what the standard is. The title is a bit more of a click bait but the challenges are still good to practice doing. I do think being able to demonstrate you can build something basic in react does sell yourself as a developer. If a company is confident in hiring someone who can reverse a binary tree, then that’s up to them. I personally don’t want someone to spend the first month of their paychecks learning react if I was running my own business

    • @Immacio
      @Immacio 2 ปีที่แล้ว

      @@WebDevCody Thanks for the reply and your insight. You make a good point about paying someone to learn react in their first month. Keep up the dope content, I've been watching every single video you've put out for the last few months

  • @_cmr211
    @_cmr211 ปีที่แล้ว

    I have had so many problems with referencing the same object with Array.fill() that I immediatelly saw your mistake and was like "Oh no" xD

  • @SocksYTTV
    @SocksYTTV 2 ปีที่แล้ว

    what extensions do you use for those inline error hints and colored block markers? also i like your stuff :)!

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว

      error lens and rainbow indent

  • @caick7
    @caick7 2 ปีที่แล้ว +1

    Hey, what's your thoughts about using declarative methods instead? Do you think it would look better for the interviewer? ex: instead of for...for... using response.split(''), grid.push(response.splice(0, 9)) while length>0, etc, etc...

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      Sure, either works. Idk about looking better or not, those are non important implementation details to me.

    • @jollyjoker6340
      @jollyjoker6340 2 ปีที่แล้ว +1

      Yeah, I think those oldschool for loops should be avoided. Good thinking on the splicing; my first thought was to do solution.forEach((n, idx) => newGrid[Math.floor(idx/9), idx%9]=n) but that still uses idexes unnecessarily

    • @jollyjoker6340
      @jollyjoker6340 2 ปีที่แล้ว +1

      And the other way at 32:00 could just be grid.flat().join('').replaceAll('0',.'')

    • @caick7
      @caick7 2 ปีที่แล้ว

      @@jollyjoker6340 Yea. Declarative programming was the most beautiful thing I found out in 2020, makes code so more readable, right

    • @jollyjoker6340
      @jollyjoker6340 2 ปีที่แล้ว

      @@caick7 I want to avoid potential bugs too

  • @Bukosaure
    @Bukosaure 2 ปีที่แล้ว

    You deserve more subscribers

  • @havefun5519
    @havefun5519 2 ปีที่แล้ว

    Cool tut especially using the debugger to debug

  • @kozmicluis2552
    @kozmicluis2552 ปีที่แล้ว

    Why is it being transposed, that's my only question. It feels bizarre to me... is it because of CSSgrid?

  • @0kJaymie
    @0kJaymie 2 ปีที่แล้ว

    Awesome content. Did you get Lasik by chance? No glasses this time 🤓

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      nope, I just left my glasses down stairs and I was too lazy to walk back down to get them

    • @0kJaymie
      @0kJaymie 2 ปีที่แล้ว

      @@WebDevCody Haha nice. I wouldn’t be able to see without mine

  • @Урал-и1б
    @Урал-и1б 2 ปีที่แล้ว

    Great video thanks!

  • @deketh73
    @deketh73 2 ปีที่แล้ว

    I think it would've been better to use a ref to read the content when required and not triggering a render each time the user writes a number. It would probably not be a problem here because it is supposed to hold a single number but when your using the input for a long text the lag is pretty noticeable as you press the keys faster.

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +2

      Yeah that might be a good useCase for uncontrolled inputs

  • @miha7273
    @miha7273 2 ปีที่แล้ว

    Interesting and educational, thank you.

  • @MarkJKellett
    @MarkJKellett 2 ปีที่แล้ว

    Only thing is here you are starting with the UI. The logic of how this works (state manipulation) is separate from the view (grid).
    It would be good showing that process as that is a much more professional practice

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +3

      It doesn't matter where you start as long as the end goal is the same. Every person's brain solves problems differently, and some people like to solve the visual aspect of the problem before solving the logic. "much more professional practice" is a snobby view point imo.

    • @MarkJKellett
      @MarkJKellett 2 ปีที่แล้ว

      @@WebDevCody When I say professional I didn't mean it to sound snobby. And people do solve things in different ways.
      But it is also true that there are multiple things to solve and it's a good approach to identify them and consider them separately.

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      @@MarkJKellett yeah that makes sense.

  • @capt8
    @capt8 2 ปีที่แล้ว

    styling to remove default arrows on number input
    /* Chrome, Safari, Edge, Opera */
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    }
    /* Firefox */
    input[type=number] {
    -moz-appearance: textfield;
    }

  • @paulm9400
    @paulm9400 ปีที่แล้ว

    This challenge is good for interview question.

  • @SeibertSwirl
    @SeibertSwirl 2 ปีที่แล้ว

    Good job babe!!!

  • @brunoqueiroz5443
    @brunoqueiroz5443 2 ปีที่แล้ว

    I don't know how to make good commits 😞😞😞😞😞

  • @grenadier4702
    @grenadier4702 ปีที่แล้ว

    This is not a good idea to change nested arrays like "array[i][j] = value". You still mutate your state which should be immutable. Kinda a proper way would be like this:
    ```
    const newArray = [...array];
    newArray[rowIdx] = newArray[rowIdx].map((val, colIdx) => colIdx === _colIdx ? newVal : val);
    ```

  • @DioArsya
    @DioArsya 2 ปีที่แล้ว

    Amazing!

  • @emalibella1228
    @emalibella1228 ปีที่แล้ว

    Amazing

  • @lonnybulldozer8426
    @lonnybulldozer8426 10 หลายเดือนก่อน +1

    I just realized that you wear a little tiny hat, if you catch my drift. Why does TH-cam keep recommending so many of you to me?

    • @WebDevCody
      @WebDevCody  10 หลายเดือนก่อน

      No clue what you mean 🫡

    • @lonnybulldozer8426
      @lonnybulldozer8426 10 หลายเดือนก่อน +1

      @@WebDevCody I can't say it directly for obvious reasons, but let's just say your last name gave it away.

    • @WebDevCody
      @WebDevCody  10 หลายเดือนก่อน

      ​@@lonnybulldozer8426 nah, I'm Christian, not that is makes a different when teaching coding. One can't choose his last name 😎

    • @lonnybulldozer8426
      @lonnybulldozer8426 10 หลายเดือนก่อน +1

      @Cody You and Mr. Hotz, eh? I'm noticing a trend here. Also, if you can't choose your last name, tell that to John Stewart.

  • @vishnyo
    @vishnyo ปีที่แล้ว +1

    Should be used flat map

  • @thespiritualjourney369
    @thespiritualjourney369 ปีที่แล้ว

    damn. u made it soo complicated. haha.

  • @LiIRobJr
    @LiIRobJr 2 ปีที่แล้ว

    Two things right off the bat
    - it’s pronounced SU DOE KU
    - please tell me you already knew that the puzzle was 9x9 before recording this video and that you only counted the cells to teach viewers

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      I’ll leave that a secret just for you

    • @LiIRobJr
      @LiIRobJr 2 ปีที่แล้ว

      @@WebDevCody ❤️ 😂

  • @yourdadishere
    @yourdadishere 2 ปีที่แล้ว

    Says intermediate. Console.logs solution. Takes almost a half hour to solve it.

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +1

      Not sure what your point is?

  • @darkmift
    @darkmift 2 ปีที่แล้ว

    Spread is a shallow copy.
    I default to json.parse(json.stringify(obj))

  • @HarelTussi
    @HarelTussi 2 ปีที่แล้ว +6

    Hey
    Instead of parseInt(e.targer.value) you can do e.target.valueAsNumber

    • @WebDevCody
      @WebDevCody  2 ปีที่แล้ว +3

      Oh nice never used that but that’s cool!

    • @jordyvandertang2411
      @jordyvandertang2411 2 ปีที่แล้ว +1

      Thats cool, does that also handle the NaN cases or would it throw an error?