Prototype split()

Hi there,
I am working at the moment on the intermediate JS challenges ( “JavaScript Practice: Arrays, Loops, Objects, Iterators”, task 2). I found a piece of code I know now, how to use, but I don’t really understand. Hopefully, someone can explain what exactly the code does, or why! it works.

const string = ‘summer’
var count = string.split(char).length - 1;
//logs: 2

Many thanks upfront!

The code as you provided it does not log 2, it throws an error instead. Because ‘char’ is not defined.
Please provide all of your code and make sure, it is properly formatted.