Mark As Completed Discussion

Good afternoon! Here's our prompt for today.

Valid Numeric String

You are working as a software engineer at a company that develops a financial trading platform. Your team is working on a new feature that allows users to enter numeric strings into a text field and have them parsed and converted into numbers.

One of the requirements for this feature is that the numeric strings must be valid. A valid numeric string must consist of:

  • A sign character (either + or -).
  • One or more digits.
  • A decimal point . followed by one or more digits.
  • An e or E followed by an integer.

For example, all the following are valid numeric strings:

SNIPPET
1"+"
2"-"
3"123"
4"-123.456"
5"1e10"
6"-90E3"

while the following are not valid numeric strings:

SNIPPET
1"abc"
2"1a"
3"1e"
4"e3"
5"99e2.5"

You need to write a function that can be used to determine if a given string is a valid numeric string.

Valid Numeric String

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's a video of us explaining the solution.

To change the speed of the video or see it in full screen, click the icons to the right of the progress bar.

Here's our guided, illustrated walk-through.

How do I use this guide?

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.