Transcript from the "Flush Operation" Lesson
>> Brian Holt: So let's try flush operation. Flush operation. This is gonna take in the int buffer that we got from above, which is called the same thing for continuity. And then we're just gonna ask a bunch of questions here. We're just gonna say, if previous operator ===+. Again, you could do this with a switch statement as well.
I'm just gonna stick to if and else if, that's what my notes say. Then I'm gonna say runningTotal += intBuffer.
>> Brian Holt: It makes sense. If this press +, then they want it to add.
>> Brian Holt: And let's just, I'm gonna copy and paste this a couple of times so else if.
>> Brian Holt: Or we can just write it out. Else if previous operator ===-. Then running total, -=. Or you can say = running total- that. But I'm just gonna use -=, yeah?
>> Speaker 2: Could we use the switch statement here?
>> Brian Holt: Absolutely. Yep, I'll stiff previous operator, === and times running total times =.
Again, that asterisk is how you do multiplication. Into total. Or not buffer, better. Otherwise else running total /= which is /= and puffer. Okay so this is working.
>> Brian Holt: I notice that it is doing in the correct addition down here like what we would expect. Times by 5.
>> Brian Holt: Let's go one step further up here to the handle symbol and see what symbols coming in here. [SOUND] So as you can see here, I use console.log everywhere. Okay, so I'm gonna say.
>> Brian Holt: So if you're using a Mac, that's control command space, brings up this little guy. And you can do multiplication. And it's this one right here that we want, multiplication sign. So here my HTML, I have like the divide and LIRR. I'm just going to right click on this one, the multiplication is the Inspect Element right there.
[00:04:18] You're gonna have to do that with if you have the minus there as well, you can have to do that with minus if you have it there with addition, so on and so forth. You have to do the HTML as well. No don't don't do it in the HTML.
How would the function look at those a switch like where would previous operator ago It would look like switch previous operator. Case, plus running total plus equals into buffer.
>> Brian Holt: Break, case- so on and so forth. Does that answer your question?
>> Speaker 2: Yeah, it does.
>> Brian Holt: Cool.
>> Brian Holt: Probably a bit cleaner to do it that way, but either one of these works.
>> Brian Holt: So now hopefully if we go in here to console.
>> Brian Holt: Tell it bigger here. So refresh, I would say 5.
>> Brian Holt: Make this a bit smaller, -2 +, so that's correct, 6. If I hit multiplication, I'm gonna expect to see.
>> Brian Holt: 9-, okay so yeah, that seems like it's working, okay.
>> Speaker 2: Does it show up on your screen?
>> Brian Holt: We haven't written to the screen yet. We have not written it to the screen yet. So you should not be seeing that yet. So I'm going to get rid of these console logs, cuz now the stuff works the way that I want it to.
You can leave them in there, but in general you don't want to ship code to have console logs. It's just kind of a messy thing to do.
>> Brian Holt: It should be for debugging purposes, and then you should get rid of it.