So it’s almost been a week since I posted my Javascript challenge and I’m not surprised by the response it received or lack thereof however I’d like to thank Lenny for taking part and teaching me a few things about Javascript along the way. Below is his implementation, followed by my original version at the end.
What was learnt
- All properties of an object can be accessed via []
- By default, Javascripts join method uses commas for it’s delimiters.
- A more elegant solution for my problem.
After seeing this solution and how ugly it made mine look, I finally made time to start reading ‘Javascript: The Good Parts’ by Douglas Crockford and soon came across the section called ‘The Bad Parts’. The third point to this chapter was entitled ‘eval’; I had a feeling this would apear here and below it described a similar situation to my own.
After finding that a solution to my problem was sitting right there infront of me the whole time I started to become intrigued about similar scenarios to this and how they were eventually solved. So if something like this has recently happened to you, let me know by posting a comment below or find me over at twitter.
