I'm passionate about web development and design. A team player who treasures effective communication. Eager to learn as much as is humanly possible on my road to web-development knighthood(haha).
Location
Nigeria
Education
Bachelor of Engineering, specializing in Electrical and Electronics discipline
.slice(), .substr() and .substring() can all achieve this but I agree completely that it should be done with the fixed indexes since its quite apparent the data is all in the same format given his example and glad that my first thought was apparently the most efficient!
edit: turns out substr is non-standard and substring should be used instead
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great post!.
Whenever I'm in a position where I can implement different solutions to the same problem involving strings, I try to follow this decision tree:
I always try to write solutions with as few lines as possible without compromising readability.
For your task, this also works:
Wow this is brilliant, didn't know you could do that in just one line of code. Thanks for sharing Fidel, I appreciate it!
If it's a fixed format you can just slice it out without having to spend CPU cycles searching.
The methods in the article are definitely handy to have in your toolkit though.
.slice(), .substr() and .substring() can all achieve this but I agree completely that it should be done with the fixed indexes since its quite apparent the data is all in the same format given his example and glad that my first thought was apparently the most efficient!
edit: turns out substr is non-standard and substring should be used instead