Variable Is Not Iterable Javascript Substring Syntax