JavaScript function reversePrint for test in Yandex