Skip to content
Advertisement

How can I get an array from an If statement?

I’m trying to detect conditions of a string length within input fields. I need to know which condition(s) is met from the if statement and then put that/those in an array to display. Here’s my code:

JavaScript

Advertisement

Answer

You can use foreach.

JavaScript

Working example

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