Function Within Function In Javascript Mdn Array