Add loop statement to JavaScript and Python