Mock Technical Interview - Javascript Developer Entry Level

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we need this to not happen if this so and we need this to happen there we go everyone that's the solution right there all right hey everyone welcome to come to the channel we have a special episode for you today it's uh me Nadder here as usual but I have uh my friend Eli over here with me today yeah Eli would you mind introducing yourself yeah uh wait that like you want me to say what uh what I've been yeah just like just a little bit about you and then we'll I'll ask you some questions about your coding journey and stuff in a second okay yeah so I uh yeah I'm like 29 years old so I'm kind of old so uh yeah I mean you know initially I dropped out of high school and then I you know I did construction for a few years and then I decided to go back to go to college I I studied math like up a second year math I did most of second year and uh then I dropped out to play poker and I did that for a few years like online so like a lot of studying study groups uh solvers simulation stuff like that and then uh you know now I'm now I'm studying programming nice uh that has been a good uh at recommending some past for me to go down and stuff so far yeah to be kind I love it I love it you see this guy is uh he's getting old you can see it as a gray hair is over there 29. I do have some great grandpa over here um all right so the purpose of this video is to uh just have some fun a little bit switch it up but also to uh to get some practice with the programming style of interviews right so uh eventually uh Eli and others uh watching you're gonna have to go through this kind of thing yourself um and the funny thing is Eli as she you and I actually recorded this um yesterday and uh I don't know how to use computers and uh for forgot to record your sound so I only had my sound um so this is actually our second run through uh but uh we're gonna do a kind of mock interview right and um we're gonna ask new questions over it totally new questions right so Eli has never seen these questions before I wanna I wanna make that clear um I wouldn't lie to you about that this is on purpose so we can get the kind of the raw and unedited um feeling here together and also just to see how how you you think on your feet um so yeah we're just gonna have fun with that kind of see how it goes I'm gonna try to pretty much have either no editing or minimal editing to this just so that we can get the real sense of what the interview would be like but the purpose of this is just to see someone else kind of going through it uh it's uh I'm very uh proud of you live for uh being comfortable doing this it's a very nerve-wracking thing uh so he's a confident guy to be able to do this and it's building his confidence as well but um if any of you are interested in doing this as well in the in the future and you love seeing how much Eli's getting made fun of on on the stream here definitely let me know and we could probably do that as well uh but the the purpose really is to kind of we're going to start with uh I guess I'll mention the agenda uh just for you Eli as well as for the audience um I'm just going to kind of go through a little bit of introductions and then uh some kind of not basic but like a really high level uh technical questions um just about JavaScript in general I just want to hear kind of how you think about them uh without coding just just kind of your your understanding of the basic concepts um and then we're going to kind of go into a warm-up exercise together we'll actually share my screen and you can have a chance to kind of pair program with me I'll give you a bit more information on that and then we'll go into a harder one and we'll see see how you do on that one um so uh yeah I guess uh we'll we'll just get started to have some fun and then we'll um kind of do a recap at the end and kind of see how it goes and and kind of what uh what went well um sounds good sounds good all right let's do it so yeah to start so you told us a bit about yourself already a little bit but kind of maybe talk to us a little bit about your Learning Journey right so you um coding is a very different kind of thing to get into um but you've been enjoying it but also not enjoying it at the same time so there's a lot of ups and downs right as with most things so how is that process been for you like like where did you start where where did you go uh kind of like did you take breaks along the way how was that whole process yeah at the start I was really excited and I still am excited actually about uh being able to do like really big projects and stuff like that but uh yeah along the way it's it's been really frustrating because I don't think I have the natural personality type uh for coding I think that it would be really good if naturally I wanted to Tinker with stuff and uh do um kind of be excited about fixing like bugs or fixing problems rather than like annoyed by it so I think that's one thing and yeah rather than being perfectionistic about which is really bad trade for in my opinion for for this and in a lot of ways that trying to uh understand everything a hundred percent before moving to the next thing rather than just trying stuff out and being okay with it not working uh I kind of think that's kind of that's something that uh I think is important right being willing to fail being willing to try stuff and fail rather than trying to make sure you do everything perfectly that's really good so you're getting better at that you feel well I think it's my tendency is to not be good at that but yeah I mean I'm working on it yeah cool so a little bit Yeah is there anything that you're really really enjoying out of the kind of just programming in general that's very different from what you've done before yeah some of the concepts are super interesting and it's kind of like it's kind of magical how like the internet works I mean or how things work not that I even know that's it's kind of a mystery to me that's good I probably shouldn't say that interview no it's fine it's fine day by day you'll you'll get better right um I guess that brings us to another good point like this the purpose of this interview is Eli is not um an expert by by any means right and he's he's a beginner he's starting he's using this as practice and he's still learning and the goal is to use this as practice for a real interview uh maybe a few months down the line or however long ends up being so he's still kind of going through that uh some courses and practice um and uh he's pretty far along but he still has a bit more left to learn before he'll probably be comfortable to to do that I I just want to say one thing also is that like this stuff I am learning right now is totally different than what matters going to be asking me about today or even the topics in general so just for fun where are you right now like just so everyone knows what you're kind of been working on recently yeah I'm doing a course called Full stack open it's a react.js or so it's just for full stack uh development generally and yeah I'm just working on react right now and uh well uh devops back-end stuff so I find that kind of annoying and hard so I don't know not really interesting to me but yeah well yeah it's also good to know what you don't enjoy right so that's good yeah um so how do you feel about getting into a couple of questions here that's true man all right so like I said these are going to be uh conceptual to start and then I'll let you know when we go to the the the real uh meat and potatoes per se of the coding questions okay okay so uh let's go with this one what is an array in JavaScript and uh what do you use an array for that array is a way to well I'll start with the second one first oh sorry uh the first so an array is a way to organize um data you can you can put it in um an indexed uh like basically oh my God matter you know we're gonna have I'm kind of we're cutting this out I don't know we're leaving we're leaving this anyway this is the raw and unedited it's gonna be great it's gonna be great the nervousness just for everyone listening the nervousness yeah I appreciate it right you're probably sitting there now sorry to cut you off here but you're probably sitting there being like Oh my gosh I can answer this question in the back of my hand but it's different when you're in the hot seat especially this seat right here that you sit again it's different the Mind melts a little bit so sorry to interrupt go ahead Eli let's talk about guys so let me because there's so many directions that one could answer such a question and yeah that it is kind of hard to organize your thoughts and decide on a direction to go in absolutely so okay an array is something that um well it's a bunch of elements it's well it doesn't have to be a bunch of elements at all actually it's it's a way to organize data yeah good that's what an array is and what was the other question uh what do you mainly use these arrays for like what's the purpose of them you said cannabis to organize data but like um so like what what is that structure you mentioned a word there before in index what is that yeah so an array is defined such that um uh each however many elements each element has an Associated index with it so that um a user or a person that wants to manipulate the array or do something with the array can uh use its associate use its natural indexing the index to the uh select a part of select a element from the array or do something with the array whatever they want to do I mean really okay and um yeah programmers have luckily made a lot of methods so that we can do stuff with arrays okay yeah we can do with a lot of stuff for the rest yeah cool um so here's kind of a follow-up to that then uh what or when I guess should I say would we use an object in JavaScript instead of an array yeah we would use an object when uh we want to have keys associated with some values okay right so yeah if we want to be able to instead of using indexes to use some named uh value to search stuff okay because indexes are just kind of like arbitrarily where they're just the same they're just by like defaulted so and they don't they have no meaning so objects just put meanings to okay so it will be like an example of like an index versus a a named key that would be more valuable yeah so you could have like a a nested object like a person object and then you can have um you know like a nested uh like Hobbies of the person and then you can have things like that so it's like you can just organize the data okay okay um in an understandable human way whereas in Array is just you're gonna have a bunch of numbers yeah yeah numbers or something it doesn't mean anything okay makes sense I like it um so similarly this is another tricky one um high level as well so very open-ended and this is meant to really tease your brain and see how you think in narrow things down so I asked you what an array is so what is a function in JavaScript and how would you describe it okay well function um well well I want to say the reason why we have functions in the first place we have functions so that programmers don't have can can uh use reuse code so that you can make code so that you can it can be utilize anywhere you want right right so that's really nice and so that's kind of so a function is kind of can be pretty much anything you want um the main difference is that uh yeah the main difference is you can just reuse it okay so is there anything else that comes with functions that makes them particularly useful uh specifically like if you think about how you you know might call a function or use a function like what do we provide to functions what do they give us back oh they gave us back uh values okay right so you well you can return um pretty much anything you want again you can return a function okay a function can return a function or can return whatever you really want getting fancy yeah I just don't know so so I guess there's a there's like the arguments and parameters right so we can provide an input and then we can maybe get some output but generally speaking we can reuse that code inside uh given that input and output right yeah sure yeah it's good yeah I mean I wish I could I I mean there's a ton of stuff that one could say but I don't know what would be valuable really so um let's build on that slightly so what's the difference between regular function and these new things in JavaScript called async functions yeah okay um regular functions once they're called the the return value comes out before um before it the the compiler reads the next line of code after the function okay okay right so it's it's like it's truly line by line but whereas asynchronous um well if it's async await yep that's different because it will wait for the I see audience but in general if you don't have async or weight then um the the code will be rendering and rendering is that the right word running it'll be running in the background yeah whilst the compiler continues to read right the rest of the code right so you're gonna get like it's going to mess up your uh yeah yeah so I guess there's like this concept of synchronous which is kind of what you're you're describing with like the the top down line by line um kind of idea and then asynchronous is like it can do other stuff while this other code is running over here right right async makes a promise um and you have to you have to wait some real amount of time exactly some some actual like not a trivial amount of time right in terms of code right to wait for it to be done good good um so now I just want to end this set of functions or a set of functions I'm talking about functions too much a set of questions thank you um with uh with a really high level one and I I like you to it's a hard question but just think about it for a second you don't respond right away but I want you to really walk me through uh your process for this okay so let's say I am coding and we're on a team together and I have an error in my code and it's JavaScript code okay and I say oh my gosh I have an error it's a syntax error it's a type error it's some kind of error okay and I say Eli uh I need your help um are you like I know you're good at JavaScript and I'm just struggling here I just can't see it I can't figure it out I'm going to share my screen uh take a look with me please help me out all right what's going to be the process like how do you approach solving errors and debugging programs okay so we're assuming that we're not that that person doesn't or that you in that case doesn't have any um software running that's helping you find errors correct and just just plain old JavaScript I'm just running the file to see if it works and it's not working I get an error well first of all you'd read the error okay like that's actually important you have to actually read the error what does it say very good uh what is it what lines is it pointing line or lines is it pointing to very good so you might have a uh like an ah but I won't talk about that actually yeah so so you might have that well you'll have that and then um if you don't already know what the error is then you can um well you can copy paste it in Google right to get more information about what it is that you're talking about if you don't recognize what it is already right and then um you know first of all you just read the line of the line of code first of all after that you'd read the line of code and see if you can understand um why that's an issue um and then uh let's see so after all that it doesn't work yeah so for instance if the line of if the line of code that has an errors inside a function you would read line by line the whole function that function I guess that doesn't work you'd see well okay you'd kind of go a step further out and say okay well what are the things that are required to be the case right that need to be okay to make the function work properly so you would look out of scope right and see if there's any problems like with that information transfer right that's going on right and you you would instead of using the whole you would actually isolate that function yeah and run it in a separate uh like outside other body right to make sure that everything's okay inside the function very good right so yeah and then you kind of work it out like that I would say that's really good I really like that answer that's uh like a very methodical kind of approach to it and you had many different suggestions right like you had Google and you had read the error and you had you know pull it out of here and try something else over here right um it's perfect I think that was really really well answered um good job thanks yeah um of course it goes more and more and more there's more things you can do but yeah yeah they get less and less useful as you go further out because yeah do the most useful thing it's really important right like I think the way that you answer that also shows that you have some experience with these errors right like clearly you've done this before you've felt the pain you've had some errors exactly um so yeah um cool so I think um I think we're good there uh you feeling okay yeah yeah okay yeah I feel okay let's uh let's go to some I'm going to pull up visual studio code and I'm gonna share my screen with you and I have um two questions uh we'll do one warm-up and then uh I'll have a more challenging question that's really meant uh I don't even anticipate I was fully solving it basically I just want to see how far we can get in your thought process does that sound okay sounds good all right let's do it so uh I'll share my screen here and um share we go are you able to see my screen okay yeah let me make sure I have the pen that I can right so forth in case it's gonna set up my uh our grid here real quick while you do that all right perfect there we go all right you're good okay I don't know if I need to be this big but maybe I'll just do like this there we go so um for the first one here um let's uh this is the warm-up so again with with these questions I just really want to reiterate the the kind of way that we're gonna approach this is I'd like you to think that I'm uh on your team and I'm struggling with this code and I've I can I reach out for help for some pair programming and I want you to kind of walk through this with me and we're gonna do a little bit back and forth if you get stuck I'll try to help you a bit and then uh you it's mainly you driving this and I'm kind of just coding it out and you can tell me line numbers and draw on the screen things like that but just really enunciate as much as you can as as you're going through this process uh because the whole point is to see how Eli thinks about these problems uh sure all right so uh warm up um we want to write a function and this function accepts one string as an argument all right this function should capitalize only every other letter in the string and then it should return that string okay there's a few nuances in here so um how do you want to start okay so let's um well first I want to come up with uh some cases or first I want to clarify the question okay okay right to make sure we understand like what exact question I like it I like it okay so the functions should capitalize only every other letter in the string okay so we have a string now if there no first of all if there's no letters in the string good question so uh if there's no letters so if we if we have an empty string is what you're asking yeah do we want to do nothing or we do we want to go through our we return do we want to go through our code and see that we have to do nothing after that we want to return an empty string if we give it an empty string okay yeah okay so it doesn't matter how we return it as long as it returns empty string yeah okay now okay let's see so only every other letter in the string so that's not every other character letter oh good good distinction you know what I'd like you to treat character and letter is the same thing for the purposes of this question very good okay so if there's like 10 spaces yeah or like a space and a yeah so letter is the same thing as character yes exactly okay that's good to know yeah okay now let's see here function I'm just making sure that I know exactly absolutely given that because the edge cases might make the question confusing to answer 100 this is already right because there's a few more things that you can probably clarify here but yeah go forward this is fantastic by the way you're doing great nice okay let's try to make some more let's try to make some uh edge cases actually and maybe that'll raise questions yeah sure no that's good that's good okay so let's try to see let's go with a really really simple one let's just go with hello what are we gonna get uh we should okay this is good so we should get um smaller case h upper e right smaller case h upper e and then a smaller L larger larger small oh yeah okay so let's say I want um I want the first one to start capitalized that's what I want so I'll clarify that the first letter has to be uh so starting caps at uh letter uh like zero letter one sure so this is going to change this slightly so we're going to get h e l l and then oh yep okay good already perfect what other things can you think of so we already did with the space we already know we can write that out though if you want let's just say uh yo Eli so we will get so uh and then retreating the character as upper and then lower e and Li yeah good okay what's another Edge case character special characters I think that would be fun yeah sure we'll say um hello like that and this should give us back uh pretty much the same string as here but just with the question marks right it's good yeah and then empty yeah we already did the empty one I think that's I'm trying to think of other things to clarify um I can't think of one right now so but maybe it'll come up when we code so it's okay to I think to start I like it I like the idea let's do it yeah I think it's okay to start and if something comes up then it's we can also doesn't all right so first of all we need to write uh cons we need to make a function so const uh you can write an error function or function sure I'll go with the error function why not uh what we're going to call it uh let's call it let's call it a camel letters or something camel letters sure like I don't know almost like close enough yeah that's not yeah it's not really the best name and then put string in there as the parameter okay and now we have now we know we're working with this okay all right let's see what we need to do here so we need to say whatever comes whatever so we have a string and strings have natural indexes associated with them nice good and we need to Loop through what we need to see we need to consider every kind of element of the string it's not really element yeah every character of the string right so we need to Loop through a string okay so we can do we can just do a uh through the string yeah now I'm trying to think before saying what Loop to do what kind of method to use on this okay um I think because it's a string I just use a for Loop okay yeah like a regular uh vanilla for Loop you want to use a four of loop what kind of loop you want to use uh let's just use a vanilla like a regular for looped in all right yeah vanilla is my favorite flavor too so I'm happy that you chose this it's actually my favorite color I'll just create the loop here so uh so we have eyes our index and then what are we searching for I is we need eyes uh less than less than string dot length next one length uh minus one if I start at zero or is that okay just to leave it at that length minus one wait this is less than so I guess no minus one less ten okay nice one all right maybe I'm wrong I mean that's fine off by one is is it one and it will go up by one each time sure um okay okay so what do we need to do now we have the ability to look at a character at a time in a string perfect good yes so now all we need to do is is ask if well so we're doing it for so we need to check okay what has to be true in order for us to want to capitalize them now we want every other but what does that mean well it means it has to be divisible well it means it has to be either odd or even okay okay the index index has to be ordered even the index has to be odd or even and if we want the first index to be changed yeah it has to be it's zero and zero is even even yeah so it has to be even good yeah so we want to change the even indices right yes to to we want to capitalize whatever happens to be in the evening yes yeah perfect I like it yeah okay so let's say we need a condition we need to check if it's odd so we need if if sorry if string um wait if string at I where are we are we talking about the character here sorry if uh okay so if I okay is uh modulus if I modulus two yeah is uh zero that means that we're even the case right that means we're even yeah sorry I'm just gonna no that's good that's fine that's okay okay in this case we need to capitalize um whatever's here okay which is so so that is uh two what is to uppercase yeah so how do we get the letter using what you said string and I right yeah string it I to uppercase not to Upper K so that's going to give it to us as uppercase absolutely and then otherwise we can just and this is fine for this if part of the if block so far I'll come back to the C sure no it's good and then I just want to say um otherwise um which is below that here else or do anything else else no we don't need an else for this okay now I kind of forget actually if uppercase uh what uppercase um returns so it Returns the letter uppercase and it ignores numbers and it ignores um the characters right but is it mutating the the original stringers are making it easier it makes a new string yeah strings are strings are immutable in general strings are immutable so we can never mutate the string right okay okay so we're going to have a problem because now we're going to have just a string with just yeah so we can just say uh string and I to lowercase um below this if block okay so string at I dot two lowercase yeah if it's not even then we're going to lower case whatever's there and it's already if it's already up yeah okay so I just so this just figured out an edge case okay which is um which is the case that we have a capital letter in an odd indices so we can put in the examples oh nice good very good so we're saying like if we have like even just all caps hello yeah even all caps yeah so what what do we we want to change this right yeah I want to change it we want that to be hello like that do we not want it to be all uppercase we in this case we want it to only every other letter should be uppercased oh okay so this so this code here that we just wrote would actually be working for that uh for well in my opinion yes yes for that yeah because if the yeah okay um yeah in this case this would work I believe yeah do you want to return anything from here or yeah we need to return uh uh now the problem is because this makes a new string I have to call it something yeah so so should we what do you want to do up here Loop no uh above the loop okay uh let's say let's say um maybe a mutating variable let yeah let but then we can't mutate strings uh we can it just creates a new string in its place okay right of course okay yeah no it's all right It's Tricky let um maybe we'll give this like uh let answer I guess yeah sure okay but no no we can't let's let's put let's put it as a let um like maybe like caps string yeah let camel string since you're going with the camel cereal even though it's not it's not really can't walk close enough it's not yeah it's not like camel string equals um empty string empty string okay good so we're starting uh fresh sleep yeah or you could just have it you can just initialize it without any equals and then let's say um camel string and then in the if you put camel string equals camel string Plus that string can I just do this yes plus equals yes and I can maybe you want me to do this I'm assuming for this one too down here yes yes okay and I actually really don't like the solution I would rather just use reduce reduce and make a string instead of that's like that's all right I mean we're almost at the end of this one it's just fine it's pretty close anyways it's good okay that's fine and I think that would probably work we have to return return sorry about that oh it's all right uh return camel string sorry yep there we go and this should work out all right so let's try this out so we'll do a console.log and then we'll call Camel letters and it will give it let's let's try our our test strings here so I'm going to try it with this one I'm gonna duplicate this a couple times I'll try it with our yo Eli and bear with me here while I do this I'll do the bar hello with our special characters make sure that works um and then I'll do it with our all caps hello and make sure that works sure perfect you okay with that yeah all right so let's run a node question one and oh interesting in interesting okay all right so the first one the so obviously there's issues here um so what's happening the problem we're getting there's no error but there's a bug there's a bug yeah yeah okay so in hello we're getting an extra H so it's so let's look at that first right we get our first capital H yeah but then it's adding an extra setting another eight hours so why is that happening so we come in here we have we have H or we have our hello let me start this Loop so what's happening I think is we're plus we're adding um so on the set so let's say the second um iteration of this Loop um it's going into the panel string oh man hold on I gotta I gotta like relax here for a second that's right that's fine yeah you're really close by the way this is just uh once you see the solution you're gonna uh you're gonna be like of course it was that right yeah yeah maybe maybe if you walk through this okay so uh are we well multiple times let's walk through this with hello so um we come in here with hello so what is this line doing that line is initializing a string yeah okay and uh we are looping from what to what in the case of hello specifically oh from zero which is the first index to the ah okay string dot length is the amount of things starting at one okay so we have the wrong yeah so we can get rid of probably this one right yep yeah because you're starting at zero or we're starting zero so that's fine so that fixes the O but we still have the double going on so we're close um okay so no that's correct um okay so if uh I modules two we're saying take that string that started at nothing or an empty string yep and add it to string I well whatever the string is uh string I to uppercase yeah so we get Capital H right yeah Capital H okay and then we put it we exit out of that if we exit out of the F and then what now our camel string is H and our next one comes down to the other part of the if uh statement right here yep or other part of the so that's h plus string at I which now should be uh one is it have we changed I yet well I wanted that to did wait I guess we haven't changed our yeah that's the issue we needed to be okay yeah that's the issue so we're adding we're adding the H and then we're always adding the same letter back again right so we need just an else um there right good very good yes very nice I'm used to writing it in such a way that it doesn't that I don't need else that's all right yeah uh this is the case where else is definitely useful there you go look at that okay cool very nice it feels bad though it's okay it's all right it's all right um so I guess I guess just just to recap that um that was really great honestly um I know people watching are probably just like oh my God the air is right there it's right there don't you see it um or you would do it with reducer you do with whatever um but that's not the point right the point is um exactly what you did right you you had a process to to to solve this problem right you've read the question you clarified the question to me you asked me questions about the question all these clarifying questions you acknowledge that maybe there's ones you didn't ask which was fantastic and you said you know there could be things we could discover as we go through this process but let's just keep going forward uh you came up with examples and you these are specifically especially edge cases but even simple examples fantastic really well done right um and then you kind of went through creating the function uh step by step line by line and then we had some tests right and as we had errors so we didn't have errors per se but bugs in our code uh you you kind of Revisited it and you asked you know why could this happen uh you know step line by line what is this doing what is that doing um and I think that was that was really well done honestly um and you can see right even for such a quote unquote simple question um there's a lot of nuance to it right and also I have to say um it is a lot harder when you don't have a chance to actually like what was my writing thing your annotation like normally yeah hold on yeah normally I would like click here and see the block right oh I see yeah and I would be able to see all these like I would click here I would click here to this would be part of my like understanding of what's going on right but when I don't have the ability to do that it's like I feel like kind of it's like chemistry or something yeah yeah yeah it's like I don't know yeah no that's absolutely right and uh you know the enemies always doesn't go they don't always go this way right sometimes you're in like a Google doc or you're in some other editor or maybe they're watching you code right but I think if you can do it this way you can do it anyway so so good job yeah this is definitely a lot harder than the others than being able to click on something yeah cool um yeah how are you feeling you're feeling okay I feel okay I mean that was not great but okay so this next question um art for this one are you doing good time wise by the way that's really good it's really good um I I don't anticipate I was actually solving it um if we do solve it uh fantastic the the point is not really even to solve it it's a hard enough question um I actually say hard but like a challenging enough question that even just thinking about the things that you just went through with me um is is going to be a process and an adventure in itself all right um so I don't want to freak you out at all but um just just uh like I want to encourage you actually right and those watching as well like if you're just like there's no way I could solve this problem in like you know 20 or 30 minutes it's just not possible um it's not always about that right it's about the process and kind of uh what you just went through with me just now um so if we get halfway through it if we only get like 25 through it doesn't matter right um let's see how far we can go and just uh take it as it comes sure okay so here we go uh we want to also again write a function here and this function is going to accept a string as well just like our previous one this string is going to be an HTML string okay so um if you haven't done HTML don't really worry I'll kind of go over the basics of it but for our purposes um we can think of this string as having a bunch of HTML in it so all the tags different types of tags but specifically um the div tag so the div tags the dividers they are all every single one of them in this HTML string every single div tag is missing its closing tag but it's not missing the entire closing tag it's just missing the the like this part of the closing tank the the you know the div this part right um right so I can always mix up my uh slashes here um so it effectively it has both div tags but the second one is missing the slash that's what I'm trying to say okay so the both div tags are there so there are two div tags correctly in the correct spaces but the second one is missing the closing slash in it so I have just a slash it has angle bracket nothing div and then closing bracket okay okay um so we'll think of some examples so this makes more sense together shortly but just keep that at the back of your mind the purpose of this function is to find and close only all of the dips in the string and then return the corrected version of that stream so we can assume the other tags are closed correctly only the div tags are not closed so uh you know natter over here programmed this string HTML string he doesn't know HTML very well and he doesn't think divs need to be closed so he didn't bother closing them but he structured them correctly so um no closing to export divs other other tags have closing tags we don't have to worry about them uh necessarily our job is just to close the dip tanks okay so uh how do you feel about that you feel okay I feel okay yeah um okay so I I guess I well first of all I want to clarify something if someone was writing um HTML inside a P tag um like a paragraph say like a string okay okay um and they write about div tags in that P tag the right like they write div tags in here you mean yeah and they're talking about and they're just simply writing about like say they're trying to teach someone HTML and they're writing about gifts oh I see wow look at that look at this guys it's good everyone is good as edge cases that's a really smart education well that's an edge case yeah that's an edge sure here is a do tank right yeah um so it's offense we're not going to cover that right um well we are actually but but we're going to cover it simply um okay so what I mean by that is we can assume that we need to close every other one oh every oh my goodness see how I avoided us um yeah so okay so we're not gonna try to get smart with uh trying to decipher you know inside of this P tag there's only one div so probably they don't mean that right we're just going to assume that if if there was a for example if there was a div out here we're gonna assume that they wanted to close this one oh okay I see what you mean so we might end up in the case that like we have the front tags having this which is okay uh yeah exactly um yeah second favorite controls either right okay so that was my first question all right that's very good very good so we're going to be working with a string and we want to make this is going to come in like this right so this is an example of one of the problems we'd be dealing with yeah um and we don't we we want to actually may I would I would like to make a new string okay uh personally and whenever I work with something like where I'm trying to build something out like like to build a new array or to build a new object I like to work with reduce I find it really easy personally to do that so I think I just want to take a note in my head well I might be working I might be using reduce for this it might come in handy so look I want to take note of it okay no let's see let me read the question again and see if I miss anything about or need to ask clarifying questions about the question is supposed to be HTML what we'll do is okay I think I understand that pretty well and the function's job is to find and close all the div the divs in the provided HTML string I think the question is very clear um so okay so let's come up with more cases then because I think let's do it is there anything you'd like to clarify about the question I I think I think um you had a really good starting point which is like what what about like The Sovereign deciphering the semantics of the HTML like do we do we want to do this kind of funny business and we're just gonna keep it simple right you see you see a div in Brackets uh if it's the second one you close it if it's the first one you don't close it okay now I want to kind of lay out the instructions for myself so that I know what edge cases to look for so we need every second every second what is it every second division and and it did and the div is just we're looking for uh the specifically that without the bracket in it as that's a div um that we're going to be trying to detect which one sorry uh the first part of that that would be one div tag like the div tag this one right here oh sorry this oh yeah so if we see this that is uh this is a div tag so then we are asking yes is this the first or the second one that we've seen but if we just saw this for example uh that's not a div tank I can't control Z okay yeah exactly and I saw that we don't want to be so this is not so we need to First understand that we're actually looking at divtek correct so that we can then keep track of what iteration it takes from um okay Okay so now let's come up with some edge cases or like I can come up this one hmm let's see it's hard to come up with edge cases for this because it's tough to imagine a case that would have any problems in the general soul sure and what general solves would look like very true yeah I guess here's an edge case for you so um what if we have this uh what if we have this string what do we do we sorry it's every second one you said yeah so in that case we just want um the middle div to have a uh what is that a backslash yeah oh it's a forward slash right it's going forward yeah we just want this this like that like this yeah okay yeah I think that that's good um is that an edge case though I guess it's just a case it's it's I guess so because technically this is invalid in certain Theory um so maybe you know we could decide to just add the closing one at the end if we want to be really nice and uh you know I really complete the HTML correctly we could just be like oh are we right are we missing one at the end kind of thing um so but let's keep it simple uh just every other one okay I think yeah I think we have two cases I mean we can write another just general case if we wanted to like but uh I don't know maybe it's maybe we just leave it here for now to be honest sure unless you have an A yeah let's just create one more for fun so we'll say that we have a div uh we have another div um and then we have um a P tag and we have hello right so what would this give us uh the second one so this one would be famous yeah there'd be a closing take here sorry not there I can't control Z that easily it's okay here here and here correct exactly so um probably not the most logical series of divs in this case right if we if we do it this way probably not what they intended right right um however for the purposes of this question I think this is the correct answer because you could just as well have said um oh well you know maybe they want to Nest these two dips and then I'm going to look forward I'm going to close them like this yeah yeah they could have they could have asked that yes so um let's start let's let's start um trying to write write some out some code now okay okay I don't think pseudocode makes sense with this other than just saying every second div it's not much to say I think yeah okay let's let's take it uh stab at it so uh what do you want to uh yeah let's call it um div second div let's call it second div second tip or closed closed second close yeah close there you go close second dip stiffs plural right why not yeah make it specific all right and this is going to take a string like before string and uh then we go into our function yeah just scroll down here so I just kind of want to I just kind of want to play with uh reduce right away and see what what we can start with and then uh work from there because I think you can make a lot of progress that way yeah let's do it okay let's go with um so first of all we need to remember if we can use reduce on a string which I think we can I don't know I mean maybe we can we can't let's do it it's been a while it's okay let's let's make sure that otherwise I can make it into a an array or we can do something else right yeah so so you want to do string dot reduce right yeah yeah what do you want to call these parameters let's go with ack and uh Char Char do you want the index or no um wait yeah index and let's put it at starting at it let's build a let's build the string oh the string empty string no first of all does this give us an error right away I mean um uh let's let's run node Q2 and no okay oh actually I haven't called it I haven't called it sorry oh we haven't called that I was surprised that was the main thing I've seen Eric because this is going to give us yes yes yes yes yes it doesn't make sense there you go yeah okay we can't reduce because it's not um all right um okay so let me think of a different method okay so I would yeah so if you really want to use reduce I can I can help you out I can turn this into we can make it into really quick for you into an array into a race aren't you yeah sure let's just do that um otherwise I can think of other array from and then uh there we go now now we can do that great and if I didn't know how to do that I would just search Google how to turn a string into an array and I would show this absolutely it'd be super easy to use yes okay so now we have an array of characters uh which is great and we want to check so we so this will run through um the array of characters but we need to know that um an extension of characters equals reduce first we need to you have have a way to find div sorry equals div first we need to find a way to find div yeah I like it so now we can do a series of three ifs for that meaning like if if we find a this then continue and if we find a d it wouldn't be three it would be uh uh B it would be five right okay yeah five characters in a row it would be to keep continuing with each if but um I mean I think you're on the right track there so that's basically saying like if we see if we see a opening angle bracket yeah right then then effectively you want to like Loop five times to check the next five characters yeah exactly and you would keep going down to me that's kind of like it's kind of complicated I would I would want to almost say like is in um is this string in this oh man is this a ray uh see now that it's an array it kind of wouldn't work because you could you could we could have kept it as a string and said is div inside this ring like that's just we're just fine I guess we could have but then we have to tell that maybe because uh we don't want to search the whole string for that we just want to search a subsection the next five characters specifically right yeah so that wouldn't be really good that wouldn't really be good um okay so how are we gonna with with an array how do we get I mean it doesn't have to be right you can go back to string if you want whatever you like we can yeah we can no we can't I think it would be easier to work with a string but I'm just trying to figure out like if there's anything we can do with this first um I mean there is a solution like we said for this but it would just be like a ridiculous amount of code to find this um what do you think should we try that method or go go back to you let's try this so let's say um let's say uh if the character we're looking at right now right is equal to the um the opening yeah the opening bracket then what do we know we need to do we need to ask if the uh next character is equal to a d yes so uh specifically how many times do we need to do that uh how many more times do we need to do this four more times four more times so what if what if we just Loop to that many more times in this if statement oh I see okay so if we find that we need to say okay for um so we're gonna have four we're working with this array yeah so what what do we even call it we didn't call it anything uh the actual array itself oh we can use the string I guess also this parameter is the actual array itself if you want that I don't know if you've seen that one before I have um okay then put array this is very Rarity you have to use yes probably means we're on the wrong track I think it's how good this is a discovery so sure all right let's say for um array at uh is it at I I don't know so array at so I guess let's do this that I uh yeah is what at I plus one oh we're asking his eyes yeah we're asking another well we're you don't want to do if same I mean well I thought you wanted to loop after we see the uh the triangle yeah so how many yeah I guess so I should probably clarify how many times do we need to be said four times right yeah after we find the first character we'll say let I equal zero and I is less than four and I plus plus so that's four Loops right there for us yeah okay that's fine uh I guess we probably shouldn't do I here because we already have i o here so I'll just call um I'll call this one let's do J J yeah so what do we want to do in here oh you need to change the second oh thank you thank you uh we need to uh we need to see if foreign you recommended a loop but you don't like this though we can throw out the loop I don't mind it's just one way to keep it within the reduce well I'm trying to see like Okay so okay hmm well if we wrote let's just see what happens if we write uh if um char at no if array at I plus 1 I guess we have J I mean we can probably do no J wouldn't work because J is not dependent on uh like say the string is 100 characters J can only go up to four so we'll say I plus J oh yes yes that's exactly it well that would be that would be okay okay is if array we need if if before there oh sorry yeah f infrared I plus J is this is getting really confusing yeah is uh d equals equals equals yep d then we need to say if again oh I see what you're saying um so you want to basically do this for each one of them which is why it's well like I don't want to I think it's a terrible yeah I think it would be a terrible uh solution what if we say uh const um um like let's say um div check string or something or div check so so the rest of the string we want to check is div this yeah I see a solution here yeah yeah right so we we know that we're looking at this and we want to look at the rest of this and now this string has indices so what can we do instead of hard coding this D here well I was thinking about making like an array like like this um and just checking to see if basically this would be equals to this oh yeah yeah that can be done as well yeah I think it's the same idea that you had right pretty similar yeah pretty much the same thing so which one you would do let's go with your method because uh yeah just because we already have an array I think yeah so um how do I code that up okay um we need to just check if the elements are the same okay so let's make an element let's make a let's make this let's change this to an array okay so I'll just do IV or is it not from sure okay and let's say um we're still checking individual elements oh my God we can throw this all out and we do this if you like because like when now that you've kind of uh gone because we can't say yeah we can't say are they equal because they're different it's gonna can we say um two equal signs with that with that what would you wanna uh kind of what kind of question would you want to ask there well I would be trying to ask if the arrays are equal in terms of what what's inside their what the elements are not in terms of like their space and memory which is like equals equals equals right oh exactly if if they're if the strings are basically equal to each other yeah like that's why I think the string is better like when you yeah exactly so I mean I see but would that work though if it's just two equals uh it would it would actually uh yeah it would work it would work right it would work yeah so we could just say uh even three equals would work because the strings are immutable no no if we had an array though oh Vienna array it wouldn't work yeah uh double equals would also not work I think I actually don't know I have to double check that actually I don't know the answer but that's pretty hacky I I prefer yeah yeah that's like an exploit of the equal sign um okay let's just use the string then and say um does the string at that at those indexes of the original string match that string so I know there's a function for that there's a method for that but so where where so what would you want to hear you want to do uh like like just like get like change this whole thing yeah just just let's just redo it okay I'll uh you know what I'll uh comment that out for now and I'll just come down here so I'll say uh what do I wanna do okay let's do so we just want to check this is okay by the way like this is meant to be a very challenging question I I mentioned that up front right so I I anticipated that there'd be a lot of exploratory stuff going on with this so don't don't worry if you're like oh how am I not getting this okay so as I expected all this yeah and it is a lot harder when I can't just right away test all the ideas okay all right so we had some decent progress right we started we we saw this that'll tell us to check the rest the next the next uh for indexes correct okay so let's do that again let's see um let's just Loop through the string with a for Loop okay so we'll say four let I equal zero I are you okay if I yeah and just yeah this is going to be the same as yeah all right cool there we go and let's say um if yeah this line again if Char is this if Char is sorry not Char if um string at I and I yeah is equal to this okay now we need to to see if the rest of the string after that is equal to um div which is equal to this so we need to uh this is the this is the tough part right yeah which is where uh you know we need to figure it out yeah all right okay okay I know there's a ton of ways to do this how do we again how do we get that string in front of us whatever the next four are let's make let's build a string okay okay let's build a string all right let's start before the loop for the loop let's say uh let um but uh unknown okay four but unknown four like Four f o u r oh I see I see okay yeah unknown four equal empty string okay you know what let's start it equals to the starting dipsay starting div tank like this is not the div sorry the lesson oh just the last time just less than just lesson yeah because that's going to be then we're going to have the div which might be useful right the fold it well maybe not okay all right no but that's going to be bad because we're going to be comparing it against only four so never mind okay already making and fixing bugs now let's make this string out let's make the string here so now we have um let's simply add let's just add up whatever is there we don't need to check anything okay let's add up so we're gonna do it four times four yep oh let's yep let's Loop through this now next Force thing which is zero J is less than four right J plus plus uh yes we want to do four four Loops is that what you meant yes okay okay and what do we want to do in here and we want to say I'm unknown four yeah plus equals yeah string at I plus J yeah yep okay okay now we have a string of of yeah that stuff in it yeah after the text after this exactly which is perfect now we can compare the strings which is what we tried to do in the first place okay so are they equal or not that's the question and then so that would be unknown is now we need to ask after this Loop is done completed is unknown for us still in this if State uh statement though here inside okay this for Loop no not inside that so inside here I believe wait that's in there okay never mind so we have this four Loop yeah and uh these the if statement is here and then the for Loop is in the if statement wait can you just click on this again okay yeah yeah so put it here out here yeah so what do you want me to do wait wait yeah exactly right here let's ask if if so if if unknown for equals equals equals yep um so we're asking if the string we made is equal to did this yeah aggressive and if it is and if it is yeah we need to say well we need well we haven't yet come up with something to keep track of what number we're on right so you know we could write this simpler version of the code first which is just to change all the div tags to that that would be maybe making it more difficult I don't know we'd have to re-read the code later I think it would be easier just to to keep track okay of how many times you've seen div okay yeah I like it okay so how do we do that now now you're supposed to in my opinion it's supposed to be that you're using some sort of object for this to look at the number of the object and or with this true false it switches back and forth right like you can do that okay is my object true or is it false or whatever right like sure um div tracker you know a thing can we do should we do that let's let's just keep track of maybe the number yeah just keep checking the numbers yeah it's fine let's keep it simpler okay let's let's make a counter okay um like div counters that's actually really complicated that true false like switching thing depending on yeah yeah we've seen zero so far I can see where that object can be useful probably for optimization and stuff too later but let's keep it simple okay div counter equals zero no when we find one when we found when do we know that we found one well we found one here right yeah plus one here so we'll say uh div counter plus plus yeah okay now so we're inside this for Loop still we have plus one to the diff counter and we need to then say below this here we need to say because now we know what to do with it because we can look at divcon we can say if that's right yeah uh right right below here right real right below here wait wait yeah if this is true plus one and do something here okay so if okay so if if counter is a modulus let's say modular let's say we don't know even our audio we'll figure that in a second uh modulus two let's say is uh let's take the case that we're going to change it so what do we need we need are we changing it we're changing it on on one every four other one so yeah so modulus two is one okay the remainder of one divided by two so if this now we need to do something we need to change something we need to add something the the we need to add the forward slash yes to what we need to add it to what precisely there what to the original string correct so we need to so we what index is the is the thing we're on right so we're on we're on I yes where am I we're on I but we need it in between I and I plus one so let's let's uh I'll interject slightly here I'll say that we can't manipulate a string remember that's the problem I was awesome yeah so we need to make a new string so we need to well I know that look I know there's a ton of methods like duplicating stuff or like let's just copy of something I'll give us something for us let's just say let um fixed HTML which is the result it's going to start as empty so uh we need to we can keep changing build it up yeah oh you want to build it you want to build it up as we're going along because we're going through the string one character at a time right oh okay so you want to add okay yeah I see what you're trying to do so you want to add every single character every single time it I changes why not so we need to make sure to add something before I change yes yes okay I'm just stating what's obvious okay that's good clarifying so where do we want to add we want to add at the point that we're ready to add which is after we figure out what we're dealing with exactly right here okay yeah yeah so we want to take that fixed string yep and then we're going to add yeah um I'm gonna add I wait wait a second we need to add yeah we need to add I well not I I is the index we need to add the string at all right sorry string and I yep and we need to add um string it I and we need to add the dash no or the the forward slash like this yeah and else yeah so else yeah we're going to add string it I I love it I think that makes a lot of sense yeah so now we're building the entire string and just in case where we found where we went through this other loop and we finally found that we're dealing with the thing that we need to add this at you know we can skip it everything else and just always add this otherwise yeah that's good unless it's only going to happen a very small amount of time yeah yes good and at the very end I think we should probably also just return our string right return our fixed return industry yeah that's going to be if you clicked on this after that yeah there we go perfect so let's go right there um now uh let's test it out so I'm gonna have a few of these cases here let's try these out so by the way we don't I well I don't know if natter does I don't expect this to work one bit like is something this many lines of code would be an error like 100 of the time yes uh what What's also important though is i i before I even run this I just want to mention first of all I actually don't know if this is going to work I can't keep track of this much stuff in my head my either myself um um it I I get the logic and there's logic is sound um logic makes sense also usually in an interview depending on if you're doing it remotely or in person uh you might be doing this physically on a whiteboard so it might be literally impossible to check your solution right you have to literally walk through it line by line in person together and try the different cases so that might be so you're saying like if it makes sense to the inner like the interviewer yeah but usually you want to kind of walk through it they'll give you some edge cases and they'll pump it through and ask you to walk through it line by line kind of uh so you're kind of the the executor of the code uh you're you're in node.js in that case um but sometimes they'll have test cases or if it's Google doc for example they won't run the code in the Google Doc if you're kind of collaborating on a Google doc virtually um so generally speaking is they don't always run it they they really want to just see the process and kind of the solution that you come up with so it's not always really about getting the answer but but since we have an editor up we might as well just kind of run this here so um let's see what we get here so I'll take this one here um and I do want to add as well while I'm kind of uh coding this out here that um I I love the fact that you didn't want to just keep running the code for an answer you know um I I see that a lot um when when people first start this they just want to keep testing their code which is great when you're prototyping something when you're personally building a project in your own time and you want to test it or you're working on your own ticket or something and you're testing it that's fine but generally you want to make sure that your logic makes sense instead of spamming to build something and just seeing kind of what pops out the the process that you have of actually like okay this has happened and this is happening and actually noticing bugs before we're even running the code I love that that was really really well done thanks yeah um all right so let's get this last one in here um I actually have no idea if this is going to work or not but uh I just want to be clear for the audience I'm under no delusion that that latter didn't help a lot with this yeah we're probably gonna get an error out right as I'm saying anyways so but yeah no I mean I understand that so so uh node two.js so I forgot to log this out sorry about that so I'll do it's right here I'll just do this console log oh sorry about that I'm just trying to get this bit faster my computer is lagging a little bit because of this stream but it's not it's okay all right hopefully that works um save the file and we get nothing out so let's try let's try to make sure you don't return anything I I think we returned something right here we're trying to fix HTML so we're turning an empty empty strings it looks like so that means it never goes into the block where it's adding uh something yeah so it never reaches the if unknown at Fort line 41 it never goes into those uh into that I guess do we even reach in here let's see so um if if string at I is equal to that which should be the very first character can we console log string at I in between line 34 and 35. this is a good place to actually start debugging this way I like it uh so yeah it seems to it seems like we're getting some stuff yeah div right okay so we uh if string iron so we enter into 37 and 38 let's see unknown for plus string at I plus J can we uh console log unknown for online 37-38 because this should work logically so far so that works what does it work so this is for this one [Music] um maybe maybe if I log it after the loop that might be helpful so that we can actually see um instead of see what it builds up yeah see what it actually is yeah that looks good is that what we want though actually is that what we want because I feel like we will oh I see I see I see so there is a bug here yeah yeah we we want we want the last four first of all not the first four and we don't want that many yes so we forget to what we forget to uh just start at one uh also and to go to five I guess so and then we would not have to put I no we still need iPhone stray so we want to go to Five you said one two zero one two three no one to one to five one to five but then we would be getting indexing too deep one to four wait a second Noah look if it starts at zero and it's I plus zero it's four it's just we're just getting spring at I which is not what we want so we do want to start at one and then we want to go to we I think we need to go to Five because that would be four letters four four times yeah iterations yeah three two out of five try that okay okay let's do a good note that looks a bit better it looks better so why are we getting uh like this this stuff here shouldn't we only enter when we know that this is done like sorry um I guess it's happening because we are coming in for the P tag we're coming into the p-tech so we have a angle bracket here so we say if string is a angle bracket oh so we're coming in for here too so we're always looping every time it's that so that's a little bit of an issue I guess so but um I think there's uh yeah there's another issue in here which is uh I have a feeling that this might be okay that I'm on four but we're forgetting to do something you see how it keeps getting bigger and bigger we need closure uh the scope it's out of it's in the wrong scope in the wrongs so yeah it's supposed to be unknown for not unknown unknown uh yeah that's true that's true yeah um you know you're right about that I I think also what we're getting to do though is um we're forgetting to to clear it yeah okay we can do that instead of change the scope yeah so you can just set it back to after the loop has completed unknown 4 is equal to an empty string again empty string yeah inside this form inside this button outside yeah yeah okay outside so now now we're getting back to the empty string cases wait can we still console logon known for after after all this is done after all this is done or actually put it um put it after this for Loop finishes after this for Loop so before I clear it or after I clear it before they cleared up uh not obviously before you clear of course we don't want to see the empty I'm known for yeah we just need to see div yeah okay wait yeah we're still getting some peas in here but that's okay it's a smaller bug yeah yeah that's actually I think okay because we are asking we're doing another check here right so it's gonna break yep so maybe we'll do it we'll we'll do a console.log um we'll say uh coming into the this is such a great uh bug test by the way by natter to see if it ever enters in which is our first question that we had Rick yeah so um oh we don't get it so we're never going in there we're never going in so why is that so um so we're only coming in here if if if it's this string right and if you console log unknown for here but it's weird because we get this string right here yeah but it changes here but we're also clearing it so it's never ever going to enter here it's never going to enter because we do this so we need to capture another variable or what if we just what if we just move this at the end here well what's the scope can you click here oh you already did yeah yeah can we just clear it at the end yeah because we still need to check it right this works 100 100 goodness look at that 100 the confidence I love it um okay so I'm gonna get rid of the console logs for here and let's see if we get into the fixer Eli says 100 which is very high look at that look at that okay we come in there yeah all right well we see it do we see it we see it so um so let's uh let's just do this so we're getting these as our fixed HTML which is interesting okay is that interesting is sad sad you know why it's because I is it's because I is just always the same it hasn't it never gets to change here um right here it it only changes after this yes so we need something else to iterate we need to no we just need to say no we just need to add more stuff uh cheer ah no that doesn't work we need to add character by character I I guess here I don't want to say that no no here's the thing like I guess uh the the uh the other question is if we look at our else case here this else case when is this else case running so it runs if this well if it if it both reaches here yeah that's the problem it runs if it both reaches here and isn't this we needed to always run on every I iteration right exactly which is why our streams are so small so that's why the strings are small but that doesn't fix all the bugs so first of all we need to run else we don't need this we don't need any else we need it to be we need to fix HTML plus equals line just copy this this one and get rid of that this needs to be yeah get rid of those this needs to be here yep so that's going to add every time regardless it's not dependent on any if and um so what's not happening all we need to do then yeah to see what we get yeah I think this might work man this will work it works really close really close really close really close so so we add this uh I see we need to return we need to get out of it somehow I actually want to fix this for you because I think this is messing you up so we're actually um we we want to do every other one and if we're yeah right so we want uh the even numbered ones oh sorry wait wait no no you want the odd number ones but well sorry sorry I should rephrase that question now I'm getting confused so wait I see the confusion we're we're checking on div counter so every two diff counters oh we're checking on div counter yeah we're not checking on I oh we want it to be even yeah even div counters yeah so sorry yeah oh that's okay sorry to the audience that must have been absolutely okay I mean look at that that's not bad that's really really close so um what's happening what are we missing here what's Happening Here I actually can't see the full string by the way the strings because of the cams cameras oh um if you put it lower oh I see sorry about that entering it a bunch of times actually can you can you see it now just like enter just like uh run it again without clearing the terminal oh I see sorry like that run it again oh you want to see that time okay there it is I guess you have our faces in a different spot than I do yeah mine's on the top right by default I think okay so for the second case this one we're looking for just this we have that but we also have an extra code over here since I have it covered uh oh yes sir you can actually click and drag your little uh your face the Faces by the way it's okay I can see this enough to make this okay so we have an extra one of these here that's the problem and that is if that is happening simply because this is always adding yes or not so we need to make sure that if we enter into this and this line of code runs line 46. exactly that it gets out of this but not this if this so and we need this to happen there we go everyone that's the solution right there so all right so maybe neither can help me I'm getting a bit exhausted no that's all right it's been it's almost an hour and a half by the way so uh you've done I honestly I didn't expect you to actually get this far so I'm proud of you okay I really am and I hope that everyone's uh clapping for you hopefully uh when they're sitting here watching this uh but let's do this um we can do this a couple ways uh we can create a variable to keep track if we did something in here or not um but we'll just go with a um a simpler solution I guess which is if we come in here uh then we want to do this we also want to do this which is what you mentioned yeah so let's put that in there but then we don't want to continue in the rest of the loop so we're just going to oh my goodness gracious so break uh not break we want to continue we want to go to the next one that's the key word in this video that's a that was my I couldn't remember the keyword in JavaScript in in Python it's break right break is actually the same thing but in Python and the JavaScript it's a break would just quit the loop right there oh okay but we need to finish okay so continue on finish this Loop iteration look at that oh okay look at that everyone isn't that quite impressive like I I'm very happy with that um so uh I I have to say uh to to kind of wrap this up yeah just just so many so many thoughts and feelings I want to share with you I hope you're you're not too exhausted his brain is probably melting now um but uh I wasn't prepared for this interview today so you you did you did fantastic honestly like that I did not expect you to actually finish this question um I I only expected us to get about you know Posh weight part way through and then kind of just talk about it a little bit and uh kind of finish the stream um so the fact that you actually went through this entire process I think is very helpful also for everyone watching just to see a very complex question this is not a trivial question um it seems really easy it seems easy but there's a lot going on a lot of edge cases um it's quite a bit of code as you can see right um in fact this kind of question is very similar to something you might pop up in a a real uh probably an actually higher level interview I think in a junior or intermediate interview this might be quite tricky for sure um it would take some time it might take a whole hour right which is what it did for us um but if they're not helping if they're not but you helped quite a bit yeah I guess so but also at the same time um it's your your process is what really matter and I'll keep hammering on that but like if you saw how you know while I even though I helped Eli's process for kind of approaching this problem step by step where the loops are where the checks are he even reiterated in English for himself and for me what he wants to accomplish at different steps of the way that was so critical I think a lot of the time uh what ends up happening is you you have a problem and you have this tendency and it's just to start coding and just uh kind of not articulate your thoughts and your your kind of your process what's going in your mind sometimes we forget that the person on the other side of the screen or or the table or whatever it is can't read our mind right and also how can I help if I don't know kind of what you're thinking what you're uh like where you're trying to get to right there's so many possible solutions to this and ways that we could have gone that um it's it you I I had a very comfortable understanding of where you're at during the entire interview process which was very helpful for me as an interviewer and also gave me more confidence to help you out and that you actually knew kind of what you were doing um even if it was maybe potentially in in another Direction so um that was really really well done um so articulating kind of your thoughts articulating technically what's happening stepping through line by line not getting frustrated as well was really great um and not just assuming that things are going to work um I I like it how you kind of a couple times assume the worst that you were confident but that was good it was a bit different but you're confident and um I like that right you didn't you didn't kind of give up or lose theme I know you're you're mentally drained now but um I think that was a really really great interview so I think just to sum all this up for for everyone also for you Eli um like that the overall interview was was fantastic like it was it was actually really really well done um and um you know like we we had one before this where we kind of practiced a little bit and uh because I messed up this this stream um so you you're definitely improving as we do uh more of these but um so maybe if I guess for everyone watching this is Eli's like second one for example with me right um or the second and a half I guess so we did like a trial mini trial run um yeah and uh it it it's very amazing how quickly you're improving um everything from just the way that you're structuring your thoughts and kind of your answers and how you articulate yourself from the non-technical questions at the beginning uh all the way through to the the really technical ones where we're coding them out together was was really really well done um and quite frankly um I think if anyone was to go through their thought process like this and Technical uh process like this when coding up problems now you can hopefully see it's not about the answer all the time it's very clear that your approach to solving problems your ability to collaborate and kind of go back and forth and have a dialogue with someone is is just so key to programming and working on teams so I'm very proud of you I think you did a fantastic job and I hope everyone can give a little clap behind their computers while they're watching you or wherever they're watching you um I would love to I'd love to do this again sometime and if anyone watching this uh would like some practice and it's comfortable uh even broadcasting like this that'd be a lot of fun and it's good experience around the Discord or wherever we end up doing it um but this is really what it takes to eventually get a position in the field right if you end up doing this process for the very very first time in in a live interview like where it's a real position that you really want um it's usually not going to go well right because as they say like the saying is practice really makes perfect and the people who kind of get into the top tech companies people who get into a lot of these higher positions um sometimes they're not even the the kind of the best or the smarts they just practice with the interview process a lot they practice questions they practice these types of things they they ask other people to watch them and exactly what we're doing together and eventually it comes across that confidence it's just it's just so huge I can't even explain um so I would like to add uh yeah go for it I'd like to add one thing to this like if you expect to to kind of be able to solve problems like this like in an interview kind of format it's going to be it's in my opinion you're going to have to have solved like problems that are quite a bit harder so that you have the confidence because to be able to solve something like this because like if this is the hardest problem you've ever seen and you're trying to solve it for the first time in front of people it's going to be the odds are stacked way against you it's like so you do need to but I don't know yeah that's kind of what I wanted to say I guess no that's good no that makes sense yeah um that's why I had that I want to say that's why I had the confidence because I've solved problems quite a bit harder than this and I know that I could solve it and I know there's something there if I just see a couple if not it just kind of like helps me a little bit I'll be able to kind of work through it a little bit you know so yeah yeah I kind of knew that I'd be able to do most of it myself exactly because the opposite of that is you see the problem and and your alarm bells and your head go off you're like oh my gosh I've never seen anything like this but how is this even physically possible I can't even begin to picture this right um so it just takes practice building projects and and trying some harder problems and that's the purpose of this Channel and together and I I think everyone can get there eventually it just takes practice and people to reach out to for help when you get stuck and just practice practice and it makes makes it perfect so thank you Eli um that was uh that was a joy it was really really fun um I I hope this turns out okay I can't wait to share it with you after this stream ends and for everyone to actually watch this but um honestly like you did a fantastic job and I think if anyone was to watch this um and you were to apply for positions for example in the future and they just saw this process now I really mean it I know you're laughing better okay all right it's um it's it's a big Testament to your uh abilities right even if you're not solving you know the craziest questions in the world just this process that we've been going through together um this is something potential yeah this is something that usually would take one or two interviews just to even figure out kind of your personality your approach to problems the way that you think about things the way that you communicate and technically communicate right these are all things that are that you've demonstrated uh really clearly right and um it's really good excellent okay anyways sorry uh let's let's end it there um and uh if you if you like this please let us know in the comments if you have any uh things you want to say to Eli please read them out as much please roast me in the comments roast them completely roast me I'm totally cool that's all good please do and join us on the Discord if you want to come there in real time roast them as well I'm sure he'd appreciate that as well don't all the memes and emojis Adam but again thank you so much Eli and I'll stop The Stream and I'll see you all later right thank you [Music]
Info
Channel: Tech with Nader
Views: 470,845
Rating: undefined out of 5
Keywords: javascript, coding, learn javascript, learn coding, web development, nodejs, programming, learn programming, full stack, learn to code, learn code, learn js, js, intro to js, js intro, web dev, web dev intro, full stack intro, javascript walkthrough, beginner javascript, js for beginners, javascript tutorial, javascript tutorial for beginners, javascript interview, technical interview, software interview, mock technical interview, mock javascript interview, js interview
Id: t3qZR6Qjy-c
Channel Id: undefined
Length: 96min 21sec (5781 seconds)
Published: Wed Nov 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.