Create cloth.js

- created valid index function