To be fair I think that would get you the same result as StringArray::fromLines(). It just breaks at \n and \r\n so I think counting \n seems reasonable, you’ll also need to return 0 if the string is empty.
I had a quick look to see if you could use std::count_if but I think we’re missing some iterator traits, so a simple for loop will likely suffice.
Funny that we have abstractions like juce::NewLine and juce::String (for UT8,16,32…) and that the only way to count new lines is to use explicitly both underlying type.