Skip to content
Advertisement

Program directly goes to else statement

When enter input and check for the result it only show the function from else. How can i fix it. it skips if and else if and directly goes to else statement.

Here is my code

JavaScript

Advertisement

Answer

I think you have to change your code to the following:

JavaScript

Edit: (please correct me if im wrong)

As you can see in the answer from @datenwolf you have to put [0-9] in brackets so it checks if the string contains those numbers (or letters for [a-zA-Z]). The plus (+) is required to check if the regex matches (at least) one or multiple times

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement