JavaScript: Array & basic Functional Paradigm