code to trim commented part of a string and return null if it is empty

PHOTO EMBED

Fri Dec 03 2021 15:12:12 GMT+0000 (Coordinated Universal Time)

Saved by @tolanisirius

const cutComment = string => {

let onlyComment = string.indexOf('//');

if (string.indexOf('/') < 1) {

return null;

}

return string.substr(onlyComment+2).trim();

}
content_copyCOPY

https://www.codeproject.com/Questions/5315561/How-can-I-make-this-code-better