Friday 5 May 2017

How to check if a string equals a value inside a variable

I have an issue where I'm trying to see if a string entered by the user matches another inside a variable from another module. Here is my current code

if ((a === "b") && (c == true)) {
            if (x) {
                if (x == Object.keys(y))

My y variable looks like this when I log Object.keys(y)

[ 'd', 'e', 'f', 'g', 'h', 'i' ]

What is the best way to check if x matches any of the values in y?

Thanks in advance.



via Glazbee

No comments:

Post a Comment