<body class="reviews"></body>
var body = document.body;
var target = 'reviews';
if (body.className.match('/\b' + target + '\b/'))
console.log(true);
else
console.log(false);
This code returns false. But if I use body.className.match(/\breviews\b/) it returns true.
What's wrong with it?
I tried to escape a variable in a regex, no luck.