My window keeps crashing... How do i fix that"


#1


https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/2/3?curriculum_id=506324b3a7dffd00020bf661


var Choppa = true

var getToDaChoppa = function(){
  // Write your do/while loop here!
  do {
      
      console.log("Get to da Choppa");
} while(Choppa) {
    Choppa = false
};
};

getToDaChoppa();


#2

don't have an infinity loop

general syntax for a do while loop:

do {
   // do something
} while (condition)

i don't know why you have {} after the condition, its not valid syntax


#3

oh ok then the problem is the loop itsself then?


#4

i already covered the problem with the loop?


#5

well... The window isn't crashing anymore but I'm now having problems with my syntax


#6

You can temporarily comment stuff out to help narrow down where the problem is.
When you've only got a small part left, you'll either recognize the problem or you can look up what the thing you're doing there is supposed to look like

That method is a bit crude but your code is very short so it's reasonable to make do with very simple solutions.


#7

var getToDaChoppa = function(){
// Write your do/while loop here!
do {
console.log("Get to da Choppa");
} while(Choppa) {
console.log("Get to the Choppa");
//What? @ionatan
}


#8

what what


#9

I don't understand what you meant


#10

I'm saying that if there's too much code for you to effectively compare it all to references (examples, documentation, your own memory) then temporarily remove parts so that you only have a very small amount of code that still has the problem in it. You can then look at that minimal piece of faulty code and think about what you were doing there, if for example it's some particular loop, then you can google that type of loop to get examples for how it's supposed to be used


#11

okay I think I get it now Thanks


#12

There aren't a whole lot of things going on in your code either, so you could also just add one thing at a time (look each thing up as you do)

So you could start by creating just an empty function - run it and see if it's valid code.

Then you could call it (nothing would happen yet, since it's empty, but there shouldn't be any errors either)

Then add a print in the function - now it should display since you call your function

Then put a loop around that print - since you were having trouble with how that should look, take a good look at examples or such before you do that. You could even do the loop entirely by itself outside the function first so that you get it working before you add it to the rest


It's a silly amount of extra work, but you need to figure out the individual parts before you can do multiple things at once. Split it up, do one thing at a time. Small changes. For now, until you've got more confidence in the things you're writing.


This is usually how debugging goes. Isolate the problem, rule out as much as possible, create a minimal problem that can be studied.


#13

Also, don't ever guess. Go look things up. If you're guessing that means you are writing something that you don't understand which hurts your ability to fix it. It also makes it more likely that you need to fix it, because don't really know what you're writing so why would it be right?


#14

right got it.. Google it is what you're saying?


#15

Google just about everything. For javascript look for results from mdn (add mdn in the search query)


#16

thanks going to google EVERYTHING now


#17

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.