Skip to content

Comment on You Can't JavaScript Under Pressureparent

Comments

I thought regex was overkill for that one and used:

return input.split(".")[1] || "";

I fully anticipated a test case like file.name.ext. Of course, you could still do what you're doing, but it'd be a lot more verbose.

What if it had multiple dots? Anyhow, I am on 5 hours of sleep, and already s spent6 hours coding...I just wanted to finish fast.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.