Kevin Powell - CommunityKP-C
Kevin Powell - Community4y ago
3 replies
ei

using Regex in an if else statement

hey guys, I created and logical statement with regex init but doesn't seem to work
let operation = Math.floor((Math.random() * name.length - 1))
    if(name[operation] === /\s$/g || name[operation] === undefined) return mathChallenge(name)
so basically on my statement, instead of using " ", I used regex of space. I wonder if using regex is executable and if so, how should it supposed to be
Was this page helpful?