Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • \$\begingroup\$ Could you use string.split(" ");? \$\endgroup\$ Commented Nov 21, 2015 at 15:17
  • \$\begingroup\$ @JAtkin I used .match(/\w+/g) to remove the punctuation from the words. \$\endgroup\$ Commented Nov 22, 2015 at 2:01
  • \$\begingroup\$ I saw that, but wouldn't .split(" ") be shorter or am I missing something? (I don't know javascript) \$\endgroup\$ Commented Nov 22, 2015 at 2:02
  • \$\begingroup\$ @JAtkin If I used .split I would also have to use .slice(0,-1) (twice) because B is a A. would make B inherit A. (with the .). \$\endgroup\$ Commented Nov 22, 2015 at 2:28
  • \$\begingroup\$ @JAtkin Actually I just found out that split accepts regular expressions so I could use .split(/\W/). Thanks for causing me to look that up! \$\endgroup\$ Commented Nov 22, 2015 at 2:43