Skip to content
Advertisement

Javascript – How to check if a string contains multiple substrings

I have multiple sub-strings that I want to find in a single string and if all three are found then do this, if not, do something else.

I am kind of stuck on how to set it so that if I get three “True”, I want to execute something, other I want it to do something else.

Many thanks.

My code is below.

JavaScript

Advertisement

Answer

Simply use a variable to count the number of “true”

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