Check if a given string is a comment or not | Function to check if the given string is a comment or not ; If two continuous slashes preceeds the comment var regex = new RegExp ( " . * " , ) ; var rex = regex . test ( line ) ; if ( rex ) { document . write ( " It ▁ is ▁ a ▁ single - line ▁ comment " ) ; return ; } var regexMul = new RegExp ( "/\*.*?\ ; Given string ; Function call to check whether then given string is a comment or not
function isComment ( line ) { " " It is a multi - line comment " " It is not a comment " " GeeksForGeeks GeeksForGeeks "