Would you pass this React.js interview question at META?

  Рет қаралды 58,272

Web Dev Interviews

Web Dev Interviews

Күн бұрын

This is a React interview question that is being asked at META!
react, javascript, coding, front-end, interview, software engineering, software developer interview, react interview question, react.js, web development, web development interview, technical interview.
Code Sandbox Link
codesandbox.io...
LinkedIn
/ nateazevedo

Пікірлер: 110
@rodrigorodrigues6369
@rodrigorodrigues6369 11 ай бұрын
The code could be pretty much simplified by using a derived state for either left or right items, by updating one state (e.g: left items) you already know which ones aren't as part of that list. A lot of options but in general it seems to be a good explanation, good job
@sumanmaharana7401
@sumanmaharana7401 11 ай бұрын
Bro , don't stop.. keep making these interviews videos in regular basis. Its really helpful.
@webdevinterviews
@webdevinterviews 11 ай бұрын
Thanks my friend! I'll keep them coming.
@billybest5276
@billybest5276 11 ай бұрын
I would have added a flag to each of items and render the items lists values depending on the value of the flags set . Then you just need one toggle function, less state variables.
@2gbeh
@2gbeh 11 ай бұрын
IDEAL 👌
@nil.4
@nil.4 11 ай бұрын
The way you orgenised the code was art... I tend to make a lot of messing with my components (usally because, in real world there so many errors and api). For me, I would have used tricks but thanks a lot for showing very beautiful solution.
@webdevinterviews
@webdevinterviews 11 ай бұрын
Thanks! Glad you enjoyed the video. Honestly my components are usually messy at first.
@FiorinaEU
@FiorinaEU 11 ай бұрын
If you set the entirety of the array to the left or the right side, you can just empty the checkedItems-array as the values are obsolete after being pushed to either side.
@webdevinterviews
@webdevinterviews 11 ай бұрын
Right, but the way I have it, the checkedItems array will be populated with checkedItems from both the right and left lists. Therefore, I don't want to empty out the checkedItems array because it will have items from the opposite side that should persist.
@nil.4
@nil.4 11 ай бұрын
​@@webdevinterviewswhat if you push all the checked items to move-left or move-right. Just wondering....what's wrong with that
@BenjaminFavre29
@BenjaminFavre29 11 ай бұрын
const [leftItems, setLeftItems] = useState([]); const [rightItems, setRightItems] = useState([]); useEffect(() => { setLeftItems( [1,2,3,4].map(l => { checked: false, label: l }) ); }, []); Then you can simply move the objects around (that hold the state for each checkbox) from left to right.
@jightwor2817
@jightwor2817 11 ай бұрын
@@BenjaminFavre29you can reduce it to one state, by adding placement key to the items and it will be even simpler. Second thought is that putting setstate to the useeffect is a bad idea.
@CamdynRasque
@CamdynRasque 10 ай бұрын
Great video! Though I will say not using an unordered / ordered list element for the lists hurt me a little inside haha, always gotta think about accessibility
@anubhapant5227
@anubhapant5227 11 ай бұрын
Thank you so much for creating such informative and insightful videos on React interviews! Your content has been incredibly helpful in preparing for interviews and has played a significant role in helping me and many others secure good job offers. Your dedication and effort are truly appreciated. Keep up the fantastic work! Sending you lots of love and gratitude from India ❤
@webdevinterviews
@webdevinterviews 11 ай бұрын
Wow! Thanks for such a nice comment. And thanks for the love from India. I hope to go to India one day.
@anubhapant5227
@anubhapant5227 11 ай бұрын
Is there any way we can connect and discuss things on tech?
@yangshunz
@yangshunz 11 ай бұрын
Meta doesn't ask React.js interview questions, this is misleading information.
@michael_ibeh
@michael_ibeh 10 ай бұрын
just curious, do you have any experience with Meta?
@Firstname_
@Firstname_ 10 ай бұрын
@@michael_ibehhe’s ex meta and creator of leetcode blind 75 💀
@VyNguyen-xl5ee
@VyNguyen-xl5ee 10 ай бұрын
@@michael_ibehhe's ex-Meta and the author of Blind75
@mjohnson510
@mjohnson510 10 ай бұрын
@@michael_ibehI believe this guy is a ex Staff Engineer from META
@rezaz7167
@rezaz7167 11 ай бұрын
That's it? only one video? Today I was searching for this video again, hoping to get more interview questions to solve. keep your progress up. I need to see more of these
@RA-xx4mz
@RA-xx4mz 11 ай бұрын
Very nice. A frontend focused interviewer would have liked to see these elements displayed in using an unordered list.
@rahul4tech
@rahul4tech 10 ай бұрын
instead of 2 independent function for move right left why not one function lets call it mover with argument left right and code inside it based on argument, and any some common code like removing of checked items. just a thought.
@getfitwithAbhaya
@getfitwithAbhaya 10 ай бұрын
Great Explanation dude... Really nice interview question to kich the bucket. Thanks for the video. 🔥🔥🔥🔥🔥🔥
@mayukhdevansahu5707
@mayukhdevansahu5707 11 ай бұрын
It was a nice explanation though. We can do the same thing with another way. We can just simply create an array of objects, containing some values, like; value: number, isChecked: boolean, target: A or B(initially it would be A). Function left will make all checked items target to A(which is for left component). loop through all the objects and make all the checked items target to A, and function right will make all of the checked items to target B. Finally for component left and right , just filter with target A and B respectively then map through the filtered items to populate the components. That's it🤘🤘🤘
@wahajchoudhry9659
@wahajchoudhry9659 11 ай бұрын
Yes, i did it same way.
@viditgoel2909
@viditgoel2909 10 ай бұрын
I also did it the same way but I am wondering does it affect the performance as each time when we change the checked property of any item the app will reRender as the array of objects is a state
@mayukhdevansahu5707
@mayukhdevansahu5707 10 ай бұрын
No... Multiple re-renders doesn't affect the performance of react, coz it's using virtual Dom and reconciliation for comparing nd detecting the changes in the object. Then it only applies the changes in the physical dom, doesn't refreshes the whole DOM tree. That's what makes react super fast⚡
@viditgoel2909
@viditgoel2909 10 ай бұрын
@@mayukhdevansahu5707 thanks for your explanation 👍
@ruttvikkhollam2845
@ruttvikkhollam2845 8 ай бұрын
yup did the same thing.
@cerofrais7486
@cerofrais7486 11 ай бұрын
Good video. May be the requirement was to display in same order so add a sort or maintain the order.
@foqsi_
@foqsi_ 11 ай бұрын
Good video. You kept it entertaining with your "who did that" and "what happened here" or whatever. haha. Kept me laughing.
@revanthreddy790
@revanthreddy790 11 ай бұрын
this was so useful, subbed and liked
@webdevinterviews
@webdevinterviews 11 ай бұрын
Awesome! Thanks Revanth.
@VyankateshJoshi-k4p
@VyankateshJoshi-k4p 11 ай бұрын
great video we need more of these ❤
@anchalpaswan1716
@anchalpaswan1716 11 ай бұрын
This is helpful. Please make more such videos
@webdevinterviews
@webdevinterviews 11 ай бұрын
Awesome! I'm glad you liked it.
@kadershaikh1704
@kadershaikh1704 11 ай бұрын
Great! Need more of such videos
@prajwalmegalamani7915
@prajwalmegalamani7915 10 ай бұрын
Hey we can just use the item.checked right and pass the value there?
@GoodToCU88
@GoodToCU88 11 ай бұрын
This question is quite doable. I would definitely prefer this than DS&A 😆
@nanimys
@nanimys 11 ай бұрын
Wow.. such a brilliant content!!
@vishnyo
@vishnyo 11 ай бұрын
you should have being implement it using just a single state.
@awekeningbro1207
@awekeningbro1207 11 ай бұрын
I feel like the "intersection" isn't really verbose, its more of a "diff" because you are diffing the contents of two lists
@MitrankShah
@MitrankShah 11 ай бұрын
much much knowledgeable, thankyou!!!!!
@sharmashubham850
@sharmashubham850 11 ай бұрын
Amazing explanation! 🫶🏻
@GamePlay-pl2nv
@GamePlay-pl2nv 11 ай бұрын
well done , keep up the good job
@k23raj2
@k23raj2 11 ай бұрын
good question and the great answer. please do one more solution video on same question using redux .
@dipankarmaity1591
@dipankarmaity1591 11 ай бұрын
thank you for this type content
@siddharthdutta2946
@siddharthdutta2946 11 ай бұрын
Awesome Work. Just 1 small thing, when we are updating a state based on its previous value, it is better to pass a function to setState, setState(prevState => !prevState) instead of setState(!state).
@GoodToCU88
@GoodToCU88 11 ай бұрын
sometimes setState(!state) produces wrong results. Rule of thumb is do setState(prevState => !prevState) unless you know for sure setState(!state) doesn't cause error. Boolean state setState(!state) is fine.
@sujayfarkade3289
@sujayfarkade3289 11 ай бұрын
Great!!!! keep posting more stuff
@webdevinterviews
@webdevinterviews 11 ай бұрын
Thank you, I will
@abhishekshankar6305
@abhishekshankar6305 11 ай бұрын
Really liked the video but couldnt we set setCheckedItems to an empty array every time we use the move right and move left function? instead of setCheckedItems(not(checkedItems, rightCheckedItems))
@veyselbasbaydar5665
@veyselbasbaydar5665 10 ай бұрын
great explanations for every details !!!!!!!!!
@emmanuellmiqueletti4605
@emmanuellmiqueletti4605 2 ай бұрын
really fun exercise.
@bakhtiyor_sulaymonov
@bakhtiyor_sulaymonov 11 ай бұрын
Thanks for the video
@K.Huynh.
@K.Huynh. 11 ай бұрын
thank for sharing
@webdevinterviews
@webdevinterviews 11 ай бұрын
Thank you for watching.
@HaibertBuilds
@HaibertBuilds 11 ай бұрын
Is it acceptable to use a UI library during the interview? Like MUI? And also what about CSS in JS ? Or are these not allowed
@emmanuelzakaryan7128
@emmanuelzakaryan7128 11 ай бұрын
For such a case I don’t think it would be good. You have 3-4 lines of css to make the grid look alike
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 11 ай бұрын
@webdevinterviews bro..please make more coding challenges interview videos. They are very helpful for getting jobs in React
@mohitmalhotra4276
@mohitmalhotra4276 10 ай бұрын
Suggestions 1. Use context and pass items lists with setter in context value to both list (sharing state) 2. Make lists and button wrapped with memo (performance) 3. Pretty sure Meta isn’t concerned about padding in the buttons
@onuracelik
@onuracelik 11 ай бұрын
Thank you ! What would you say for the level of this question? junior, mid ?
@setashifan3288
@setashifan3288 11 ай бұрын
junior
@aryabiswas129
@aryabiswas129 11 ай бұрын
amazing
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 10 ай бұрын
@FlowState code . I was asked this interview question recently..can you please assist me const obj = { a: { b: { c: { d: 5, e: [1,2,3,4] } } } } get(obj, 'a.b.c.d'); // 5 get(obj, 'a.c'); // null get(obj, 'a.c', 'no value'); // 'no value' get(obj, 'a.c', {}); // {} function get(o, str, defaultValue){ // Your code, it should cover all the above scenarios }
@dgoenka1
@dgoenka1 10 ай бұрын
How would it be to use Redux / useReducer / Context Provider?
@psykik89
@psykik89 11 ай бұрын
And this is the content we wanted , Thank you Nate you are posting the most helpful content on youtube Compare to others .Don’t stop posting 🫶🏻🫶🏻
@ruru-dev07
@ruru-dev07 11 ай бұрын
respect ✅✅🙌🙌
@bipingurung7504
@bipingurung7504 11 ай бұрын
Make more video about react interview coding round
@jones3791
@jones3791 11 ай бұрын
Good stuff. How can i contact you to send you some real React Interview questions?
@webdevinterviews
@webdevinterviews 11 ай бұрын
Hey! Thanks! I'm glad you reached out. You can send a message on - LinkedIn - www.linkedin.com/in/nateazevedo/ Email - webdevinterviews@gmail.com Whichever works best for you. Thanks
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 11 ай бұрын
@webdevInterviews -- I was recently asked below interview question- Display the bellow 2 cart items separately in the list on a screen e.g cartA = ["apples", "bananas", "grapes", "oranges", "pears", "pineapple"] cartB = ["potatoes", "beans", "carrots", "spinnach", "kale", "broccoli"] Add a button on the screen, on click of the button swap only the odd item from cart A, with odd items in cart B. Can someone give me solution for above problem please?
@GoodToCU88
@GoodToCU88 11 ай бұрын
I don't know this is what you mean to do. function handleClick () { newCartA = [...cartA]; newCartB = [...cartB]; swapOddItems(newCartA, newCartB); setCartA(newCartA); setCartB(newCartB); } function SwapOddItems(cartA, cartB) { for (let i = 1; i < cartA.length; i += 2) { if (i + 1 < cartA.length) { swap(cartA, cartB, i); } } } function swap (cartA, cartB, i) { let temp = cartA[i]; cartA[i] = cartB[i]; cartB[i] = temp; }
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 11 ай бұрын
@@GoodToCU88 thanks....this solves my coding interview query.
@elmalleable
@elmalleable 11 ай бұрын
super nice, if i may, you could use one list where of objects {number, flag}[] the value of the flag can be left or yellow or it may be right or red so you save on memory , doesnt really matter but sometimes you can think of ways of not making extra variables . absolutely make extra variables if it helps you or you like it
@viditgoel2909
@viditgoel2909 10 ай бұрын
are saying something like this const [elements, setElements] = useState([ ...items.map((item) => { return { value: item, side: "left", checked: false }; }) ]);
@elmalleable
@elmalleable 10 ай бұрын
@@viditgoel2909 yup. yeah this should work. You could throw it up in stackblitz and see.
@elmalleable
@elmalleable 10 ай бұрын
I would take the item keys rather than the whole item but this still works
@achuachu2565
@achuachu2565 5 ай бұрын
GOT Confused a lot
@damb133
@damb133 3 ай бұрын
Hi all, preparing for first time React job interviews. do most interviews want us to create multiple components ? or usually just stick everything into a single one ?
@webdevinterviews
@webdevinterviews 3 ай бұрын
Hey, my suggestion is to get a working prototype quickly. If there's time for refactoring you can start to break things into components. Plus, while building the prototype you will start to get an idea of what should be broken into a smaller component.
@shubhamboghara4490
@shubhamboghara4490 11 ай бұрын
Bro, do you have discord server for this channel?
@klirmio21
@klirmio21 11 ай бұрын
Noob question : Why did you use HTML Entities instead of just ">" and "
@awekeningbro1207
@awekeningbro1207 11 ай бұрын
because ">" and "
@MajdAkleh
@MajdAkleh 11 ай бұрын
How much time you have for this task?
@foqsi_
@foqsi_ 11 ай бұрын
What even is "item"?
@thip1754
@thip1754 11 ай бұрын
Did it in 15 min, could say I would pass haha
@webdevinterviews
@webdevinterviews 11 ай бұрын
Hmmm. Should I believe you?? Just kidding. Good job. 15 minutes is super impressive.
@DuyNguyen-qs2cs
@DuyNguyen-qs2cs 11 ай бұрын
your code is not good enough 😢. Better to learn more before think of Meta 😂
@nanimys
@nanimys 11 ай бұрын
may I ask you, some files are .jsx and some just .js.. why not make it common?
@omarwageeh606
@omarwageeh606 11 ай бұрын
Convention is files that don't do rendering are .js not .jsx as they dont have html while files that include and render html are .jsx.
@Randomguy48279xyz
@Randomguy48279xyz 11 ай бұрын
👍
@azhar_malik
@azhar_malik 11 ай бұрын
Bro what if we want to maintain the seq of the items as well like 1 will always be on the top and 5 at the bottom how would we do that?
@sycal13
@sycal13 11 ай бұрын
in the moveRight function, you'll use the sort method. like this setRightItems(rightItems.concat(leftCheckedItems).sort()) then just repeat the process to the leftMove function. this will sort the items in order no matter the sequence checked.
@azhar_malik
@azhar_malik 11 ай бұрын
got it @@sycal13
@cafelutsa_
@cafelutsa_ Ай бұрын
did bro get a job and privated his videos? 💀💀
@webdevinterviews
@webdevinterviews Ай бұрын
You noticed!
@cafelutsa_
@cafelutsa_ Ай бұрын
@@webdevinterviews what a shame
@RaZoRxan
@RaZoRxan 11 ай бұрын
this is how you DON'T write react code
@trinhnam3850
@trinhnam3850 11 ай бұрын
agree !
@SingularityLabsAI
@SingularityLabsAI 11 ай бұрын
Meta only ask DSA + System Design questions.
@de-ar
@de-ar 11 ай бұрын
Sorry we won't be hiring you for the job, unlike the demo shown at the beginning, your code does not respect the order of selection of the items. Better luck next time
@ParthaSutradhar
@ParthaSutradhar 11 ай бұрын
THAT'S SO COOL.
@tiagoagm
@tiagoagm 11 ай бұрын
Nice video mate. The job position was a junior level right?
Google Frontend Interview With A Frontend Expert
47:59
Clément Mihailescu
Рет қаралды 1 МЛН
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 58 МЛН
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
React Interview Questions | Beginner to Advanced
26:42
PedroTech
Рет қаралды 31 М.
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН
3 Years Experienced React Interview
1:16:16
ProCodrr
Рет қаралды 39 М.
A subscriber was asked these interview questions for a junior role
44:35
Front End Mock Technical Interview | JavaScript, CSS, React, and Algorithms
1:33:39
All 17 React Best Practices (IMPORTANT!)
1:46:11
ByteGrad
Рет қаралды 139 М.
This is a good beginner React interview challenge question
30:38
Web Dev Cody
Рет қаралды 73 М.
Senior React.js Interview Question
21:33
Web Dev Interviews
Рет қаралды 56 М.