Reduce Function Array Javascript Push And Pop Operation In C