So, the string split method takes a string and returns an array of string parts. The method expects a parameter, however, a separator element. If no delimiter is provided, the method returns only one part, the string itself. In your case, you probably planned to split the string into separate characters, which would mean that the divider would be an empty string:
var leftString = left.toString().split('');
Since you are already familiar with console.log , note that you can also use it to debug your program. If you get confused in the output of left % currentDigit , one thing you could try is to register the variables just before the call,
console.log(typeof left, left, typeof currentDigit, currentDigit)
which can give you an idea of ββwhere to look next.
source share