I am trying to do something rather simple I believe, but I am new to Javascript, and am not sure what function I should be using. I want to check an incoming string agaist a regex to find if matches and if it does then set a bool true else false. Here is what I tried:
function screenCapture(value)
{
let regex = /\.(gif|jpe?g|tiff?|png|webp|bmp)$/i;
const found = value.match(regex);
if(!found)
{
var str1 = ".png";
value.concat(str1);
}
}
note that if you need the file extension to do something else in your code is fine to use match (it should return null I think if there is no match - so your check will work the same)