Javascript: Count number of lines in a string

Published:
const numberOfLines = subject.match(/^/gm).length