javascript startswith multiple values
if (newStr4.startsWith("Mon") || newStr4.startsWith("Tues") || ...)
Or you could use regular expression:
if (newStr4.matches("(Mon|Tues|Wed|Thurs|Fri).*"))
4.25
4
//There is NO possibility to passing an Array
//like startsWith(["Mon" | "Tues"])
if (newStr4.startsWith("Mon") || newStr4.startsWith("Tues") || ...)
//although you can use regular expression,
//but performance are lower than the solution above
if (newStr4.matches("(Mon|Tues|Wed|Thurs|Fri).*"))
Thank you!
4
0
3.88
8
hi hi I tried this in Groovvy
["Mon","Tues","Wed","Thurs"].any { newStr.startsWith(it) }
hope it helps
Thank you!
8
0
Are there any code examples left?
New code examples in category Javascript