snippet to loop key/value js