Push contents of both stacks in result
while ( s1 . length != 0 ) { res . push ( s1 [ s1 . length - 1 ] ) ; s1 . pop ( ) ; } while ( s2 . length != 0 ) { res . push ( s2 [ s2 . length - 1 ] ) ; s2 . pop ( ) ; }