another thing comes in the solution of sudoku solver
for the clear button, the solution says
const textArea = document.getElementById('text-input');
const clearBtn = document.getElementById('clear-button');
// import { puzzlesAndSolutions } from './puzzle-strings.js';
//clear button resolution
const clearInput = () => {
const textArea = document.getElementById('text-input');
return textArea.value = ''; //, setGrid('');
}
document.addEventListener('DOMContentLoaded', () => {
// Load a simple puzzle into the text area
textArea.value = '..9..5.1.85.4....2432......1...69.83.9.....6.62.71...9......1945....4.37.4.3..6..';
clearBtn.addEventListener('click', clearInput, false);
});
now one has defined const textArea = document.getElementById('text-input'); once already at the headers
why you do have to define it again within the function?
but in fact, if you remove the line of const textArea in the function, it throws an error and wont run.
and changing the const to var and deleting the line, it wont work.
why?
i am just interested if any newbies managed to complete this part. it seems googling online so far i didnt see any questions or helps online, it seems no one had completed it. i am just interested those who managed to do it themselves, what material did you read?
Afaics the clearAll function is being tested, so if you delete it, the tests fail. Thatâs why itâs separated out.
Iâm not sure if it is linting rules or if itâs following on from that & to do with the tests, but you canât call document directly, anything using it needs to be referenced in a variable or use window.document instead (ie referencing it explicitly rather than implicitly)
You keep calling the example projects âsolutionsâ.
This is wrong. They are simply functional implementations of the idea - they do not demonstrate best practice.
The idea is that you look at the project and figure out how to make it. Your way.
The only requirement is to meet the user stories and pass the tests.
These projects come very late in the curriculum. If you have trouble thinking through how to implement them, I recommend going back and reviewing material from earlier in the curriculum.
To suggest that freeCodeCamp is dropping students in with no help on such a late stage project is a bit baffling to be honest. The work leading up to this point should give you lots of ideas about how to approach this.
And if you are stuck, asking for help reasoning through the ideas is going to get you a lot further than picking apart the example and complaining that itâs not the way you would do it.
hm. no. the shown code was from freecodecamp, and it works. even though it might not be the best optimized or readable solution, it is a feasible solution within the solution set.
everyone has different way to learn. learning coding is like learning mathematics, at majority of the levels in application or in undergrad, nobody is inventing anything new. in fact everyone is taking steps that someone did in the past. self-discovery is one way to do it, but it is inefficient, and not everyone has all the time on earth.
bills still come every month.
and then there is the part of imitation.
i am not here to pass tests but understand how things work and how it is written in a particular way.
that is not helpful either.
yes, indeed this is not the first time freecodecamp has done this.
and it wasnt the first time the âpast test thingâ failed.
i werent even the first one to write the same thing.
and i am here asking how it worked and why there has to be convoluted way to write it. and you are one of those classic stackoverflow people who are not helpful, in the whole thread.
Then, to back up the point made here, this is just a solution to the problem. So the reason it is written that way is because it was written that way by the person who wrote it. document canât be called directly without window preceding it in the very particular context the person who was writing it was working in, so they worked around that by assigning browser API functions that used it to a variariable. Unless you are directly copying what they wrote and adjusting it, you do not need to do things the same way. Itâs good that youâre poking around. But this in particular is an example of that FCC canât really be expected to cover everything â it is a peculiarity of the particular environment that code was written in.
I apologize for insulting you, but you flat out ignored any practical explanations despite expressly stating that was what you were looking for. And youâve ignored answers on the Reddit thread as well re improving issues with the current backend curriculum â you were pointed to GitHub issues where people are working on improving things several days ago, and youâve rehashed things again in this thread, seemingly without checking on the progress of fixes/improvements.
Again, there is nothing wrong at all with poking around in examples and asking for clarification or suggesting improvements to the code. The FCC curriculum is huge and sprawling, so there are always places where improvements can be made.
But in this case, what youâre pointing at is an example of a quite complex program someone has built to specifications. You are being asked to build a program that conforms to the same specifications. It is there for you to build using what has been taught in FCC + your own knowledge and research. The task is not to take the example and copy it.
You are also picking out tiny pieces of code that donât really have any bearing on the overall task â with both of the examples in this post, what youâve highlighted is just the very specific way the author of the code wrote out one very specific piece of frontend event handling logic. The two pieces of code just do a very minor thing each, and do not have to be written that way if that logic is even included in the way it is in the example. They are not new concepts either, and they are not backend code.
Also, in Reddit you use the example of the calculator project and not being told about eval, which simplifies the solution if you do it a certain way. But it is absolutely correct to not say to learners âuse evalâ: eval has extremely limited usecases in JS, and its use is never encouraged; in the context of the calculator project there are much better ways to program it than using eval (they are harder and take a lot more thought and research, but no-one said it would be easy)
Itâs not a game where you try to complete the tasks as fast as possible by any means: the projects are there for you to build yourself, and learn from. It is pointless just copying the existing code, or looking for shortcut solutions to get ticks on the profile as fast as possible.
I feel similar to @lychenus here. In my opinion, out of the blue, the Quality Assurance curriculum diverged dramatically from the other curriculums. It seemed designed more to be a grind by adding in lots of tedium and intentional bugs without warning. Intentional bugs would have been welcomed if they had at least been tastefully and strategically added (as well as warned about).
Moreover, the overall quality of the lessons seems to have dropped off in this curriculum. For example, I donât see the point in having students write an algorithm to solve sudokus puzzles in the middle of a certification about learning to write tests. It seems simply added in there to take up time, rather than to teach anything related to QA. I would have much preferred the difficulty of this project be related to the subject material (i.e., writing tests and maintaining backend functionality) rather than logic puzzles. That whole effort seems like it belongs back in the Algorithms and Data Structures program.
I donât mean to sound like a grump but I have grown quite frustrated with this curriculum and genuinely loved and felt like I got a lot out of all of the others prior to this one. Now I feel like Iâm grinding and no longer getting much use out of my time.
At this point, I would probably recommend other students do all of the other curriculums prior to this one and then skip this one, at least until it has been rethought out and/or polished a lot more.