XYZ (Hong Kong) interview question

explain Java script and complete machine coding test