Using Reduce Method Javascript Substring Syntax C