DEV Community

Discussion on: Day-2: 30 days of code- Hackerrank

Collapse
dakujem profile image
Andrej Rypo

Did you test your solution? You didn't. If you did, you would be surprised to find out you are missing a return statement.

Don't get me wrong, I'm not scalding you. I'm trying to give you a valuable advice.
Learn to write tests as you learn to write code. It will make you a much better programmer. Trust me.

Collapse
dakujem profile image
Andrej Rypo

My bad... "Find and print"... the task is flawed 🤷‍♂️
Anyway, much better to write console.log(solve(...)) and return a result than print within the working function and retun nothing.

Collapse
pranav589 profile image
pranav589 Author

It passed all the test cases provided by HackerRank. And ya thanks for your advice. It'll help me in the future for sure.