string of points separated by space, // and coordinates separated by comma, return array of points. var splitToPoints = (f, points) => points.split(' ').map((point) => { var [ xString, yString ] = point.split(','); // array destructuring return f(Number(xString), Number(yString)); // return 2D point as … }); var pointsJ = '0.5,0.460 0.5,0.875 0.25,0.875'; var arrayOfPointsJ = splitToPoints(f, pointsJ); // [ f(0.5, 0.460), f(0.5, 0.875), f(0.25, 0.875) ]