after reading chapter 5 of Eloquent JavaScript I’m actually shocked at the level of sophistication in the code written there. The way the author puts together the logic/sequences of thought in his code is nothing short of art.
I guess what I want to ask is - is it common for developers to be able to write code to that level of eloquence with some experience (and if so, typically after how long?) or is the code displayed in the book something only writeable by coding prodigies/ super talented CS grads?
a program to take a string and identify what percentage of whatever Unicode scripts are present in it out of the total. the program also accounts for Unicode characters which take up more than one code unit
each unicode script is modelled as such and placed in an array called SCRIPTS:
Actually many people complain about how hard the book gets after chapters 5 or 6. I read many chapters myself and yes, you freak out when you can’t follow those examples. But this is just like any language: when you begin to learn it, everything looks difficult as hell and you think you won’t be able to speak that language unless you know every word or expression. The reality is very different, though: once you get up and running with it, you will be able to move forward finding whatever you need to express more clearly one day after another. In Javascript terms, you have many resources to practice your logic and knowledge so you can improve your habilities with the language.
As of the time taken to get to this level… I guess it’s like everything else in this world. You just practice and you’ll find out yourself
I noticed myself getting stuck on exercises and what I’d do is repeat over and over until I get it. I would read other’s codes, comments, check other sites’ definitions to get a better perspective until I truly get it. I realize the examples can be hard but there’s a reason why this book is considered to be one of the best.
One thing to remember… It may have taken an hour or two to write the code. It also takes awhile to understand the code once you first look at it. Don’t be discouraged.
I’m also stuck on the Dominant Writing Direction problem in Ch.5. It’s not just the complexity of the code, but also understanding what the question is asking and understanding unicode. I think it’s doable step by step, but it’s just hard managing all the information in one run as the brain isn’t used to keeping track of all these different variables and nested data, etc. So I’m kind of stuck on what the question is actually asking as I even see one parameter example with two languages in it…??
I don’t want to spoil an answer for you, but if you want to take a look at my solution let me know.
I believe the authors intent was for you to use the countBy and characterScripts function. If you do so you don’t have to write much of your own code, but can build (refactor) on his examples.