Hey there out of curiosity this is a problem I've run into several times as a noob programmer. On occasion I have to write a line like this string.match(regExp) but I may then store that match, all good so far let matchedString = string.match(regExp), but I don't want to store a value if no match is found (this problem also applies to situations outside of strings or regular expressions).
I have to use an if statement to check the result of that line then: if(string.match(regExp),but then I have to write code that seems convoluted to store the value; if(string.match(regExp)) matchedString = string.match(regExp); needlessly repeating the initial function. Is there a workaround to this? Or a simple general solution that I've missed?