There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Why doesn’t function declaration work in this exercise?
AND
Is something remembered when I use a function declaration instead of arrow function syntax?
but i didn’t get past instruction 5 even though there where bugs falling down the screen.
then i copied the solution and reseted the exercise. first writing the same solution as before and when again instruction 5 wasn’t accepted, I pasted the solution (which uses arrow function syntax) but instruction 5 still wasn’t accepted.
Then when I reloaded the page and only used the arrow function syntax instruction 5 was accepted?!?
I used the function syntax as in the instructions (not the arrow syntax). I also got stuck on step 5 till I made the edit as below. bugGen(); wasn’t accepted. bugGen() was accepted.
Why did this code makes 2 bugs?I think this 2nd “bugGen()” update 1st “bugGen()”'s Product.
I predicted that this code will make one production.
I think I missing knowledge about javascript.
Can someone please tell me what knowledge I am lacking?
(And sorry for my bad Endlish.)
This is the function definition. It lays out what the function is supposed to do, but it doesn’t execute any statement. It is like writing a recipe in a cookbook.
When we write the statement bugGen();
now, the function is called and the statements we wrote in the function definition are executed. You can think of it as cooking the recipe we wrote earlier.
A random xCoord is generated and and then a bug is created.
When we again write the statement bugGen();
again the function is called and the statements we wrote earlier are again executed in sequence. Another random xCoord is generated and a new bug is created. There is nothing in the function definition to suggest that we are targeting the same bug for updating.