added JS solution